---
name: "im_open_local_array"
section: "3"
platform: "linux"
package: "libvips-dev"
version: "7.20.7-1+b3"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/im_open"
---

# im\_open\_local\_array(3)

open VIPS image descriptor(s)

Part of [im\_open(3)](/im_open/3.md).

## NAME

im\_open, im\_open\_local, im\_open\_local\_array - open VIPS  image descriptor(s)

## SYNOPSIS

\#include \<vips/vips.h\>

IMAGE \*im\_open( const char \*filename, const char \*mode )

IMAGE \*im\_open\_local( IMAGE \*im, const char \*filename, const char \*mode )

int im\_open\_local\_array( IMAGE \*im, \
   IMAGE \*\*out, int n, const char \*filename, const char \*mode )

## DESCRIPTION

**[im\_open(3)](/im_open/3.md)** examines the mode string, and creates an appropriate VIPS IMAGE descriptor.

**r** opens the named file for reading. If the file is not in the native VIPS format for your machine, **[im\_open(3)](/im_open/3.md)** automatically converts the file for you in memory. For some large files (eg. TIFF) this may not be what you want: you should call the appropriate converter yourself, and arrange for the conversion to take place on disc. See **[im\_tiff2vips(3)](/im_tiff2vips/3.md),** **[im\_jpeg2vips(3)](/im_jpeg2vips/3.md),** **[im\_png2vips(3)](/im_png2vips/3.md),** **[im\_magick2vips(3)](/im_magick2vips/3.md),** and **[im\_ppm2vips(3)](/im_ppm2vips/3.md).**

**[im\_open(3)](/im_open/3.md)** can read files in most formats.

**w** opens the named file for writing. It looks at the file name suffix to determine the type to write -- for example:

  im\_open( "fred.tif", "w" )

will write in TIFF format.

You can pass parameters to the conversion functions encoded in the filename string. For example:

  im\_open( "fred.tif:deflate", "w" )

will write a deflate (ZIP) compressed TIFF file. See the man pages for **[im\_vips2tiff(3)](/im_vips2tiff/3.md),** **[im\_vips2jpeg(3)](/im_vips2jpeg/3.md),** **[im\_vips2png(3)](/im_vips2png/3.md)** and **[im\_vips2ppm(3)](/im_vips2ppm/3.md)** for details on all of the options available.

**t** creates a temporary memory buffer image.

**p** creates a "glue" descriptor you can use to join two image processing operations together.

**rw** opens the named file for reading and writing. This will only work for VIPS files in a format native to your machine. It is only for paintbox-type applications.

**[im\_open\_local(3)](/im_open_local/3.md)** is a convenience function which opens an image descriptor as [im\_open(3)](/im_open/3.md), but makes it local to im, that is, when im is closed, the descriptor created by [im\_open\_local(3)](/im_open_local/3.md) will be closed too.

**[im\_open\_local(3)](/im_open_local/3.md)** is handy for saving you from adding many  **[im\_close(3)](/im_close/3.md)** calls to escape points. Example: find the total of an array of images.

  \#include \<vips/vips.h\>

  int\
   total( IMAGE \*\*in, int nin, IMAGE \*out )\
   {\
     int i;\
     IMAGE \*t1, \*t2;

    if( nin \<= 0 ) {\
       im\_errormsg( "total: nin should be \> 0" );\
       return( -1 );\
     }\
     else if( nin == 1 )\
       return( im\_copy( \*in, out ) );\
     else\
       for( t1 = \*in, i = 1; i \< nin; i++ ) {\
         if( i + 1 == nin )\
 	  t2 = out;\
 	else if( !(t2 = im\_open\_local( out, "t2", "p" )) )\
           return( -1 );

        if( im\_add( t1, in\[i\], t2 ) )\
           return( -1 );\
         t1 = t2;\
       }

    return( 0 );\
   }

This function will create many intermediate images, but does not need to close them. Any which are created will be closed automatically when out is closed by our caller.

**[im\_open\_local(3)](/im_open_local/3.md)** returns NULL on error, or if its first parameter is NULL.

**[im\_open\_local\_array(3)](/im_open_local_array/3.md)** will open an array of images, failing if any of the opens fail. It's handy if you need a number of images for intermediates. Example:

  IMAGE \*t\[6\];

  if( im\_open\_local\_array( out, t, 6, "mytemps", "p" ) )\
     return( -1 );

opens 6 temp images (t\[0\] to t\[5\]).

## RETURN VALUE

The function returns the image descriptor on success and NULL on error.

## SEE ALSO

[im\_close(3)](/im_close/3.md), [im\_vips2tiff(3)](/im_vips2tiff/3.md), [im\_vips2jpeg(3)](/im_vips2jpeg/3.md), [im\_vips2ppm(3)](/im_vips2ppm/3.md), [im\_tiff2vips(3)](/im_tiff2vips/3.md), [im\_jpeg2vips(3)](/im_jpeg2vips/3.md), [im\_ppm2vips(3)](/im_ppm2vips/3.md).

## COPYRIGHT

K. Martinez, 1992.

## AUTHOR

K. Martinez.
