Next: 3.6.2 Local memory allocation Up: 3.6 Automatic resource deallocation Previous: 3.6 Automatic resource deallocation Contents

## 3.6.1 Local image descriptors

VIPS provides a function which will open a new image local to an existing image. `im_open_local()` has type:

    IMAGE *im_open_local( IMAGE *im,
      const char *filename,
      const char *mode )

It behaves exactly as `im_open()`, except that you do not need to close the descriptor it returns. It will be closed automatically when its parent descriptor `im` is closed.

Figure 3.4: Sum an array of images

Figure 3.4 is a function which will sum an array of images. We need never close any of the (unknown) number of intermediate images which we open. They will all be closed for us by our caller, when our caller finally closes `out`. VIPS lets local images themselves have local images, and automatically makes sure that all are closed in the correct order.

It is very important that these intermediate images are made local to `out` rather than `in`, for reasons which should become apparent in the section on combining operations below.

Next: 3.6.2 Local memory allocation Up: 3.6 Automatic resource deallocation Previous: 3.6 Automatic resource deallocation Contents