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 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.