<!-- manual page source format generated by PolyglotMan v3.2, --> <!-- available at http://polyglotman.sourceforge.net/ --> <html> <head> <title>VIPS_FORMAT(3) manual page</title> </head> <body bgcolor='white'> <a href='#toc'>Table of Contents</a><p> <h2><a name='sect0' href='#toc0'>Name</a></h2> VipsFormat, vips_format_map, vips_format_for_file, vips_format_for_name, vips_format_write - load and search image formats <h2><a name='sect1' href='#toc1'>Synopsis</a></h2> #include <vips/vips.h> <p> typedef enum { <br> VIPS_FORMAT_NONE = 0,<br> <br> VIPS_FORMAT_PARTIAL = 1<br> <br> } VipsFormatFlags; <p> typedef struct _VipsFormatClass { <br> VipsObjectClass parent_class;<br> <p> gboolean (*is_a)( const char * );<br> <br> int (*header)( const char *, IMAGE * );<br> <br> int (*load)( const char *, IMAGE * );<br> <br> int (*save)( IMAGE *, const char * );<br> <br> VipsFormatFlags (*get_flags)( const char * );<br> <br> int priority;<br> <br> const char **suffs;<br> <br> } VipsFormatClass; <p> void *vips_format_map( VSListMap2Fn fn, void *a, void *b ); <br> VipsFormatClass *vips_format_for_file( const char *filename ); <br> VipsFormatClass *vips_format_for_name( const char *filename ); <p> int vips_format_write( IMAGE *im, const char *filename ); <p> int vips_format_read( const char *filename, IMAGE *out ); <p> <h2><a name='sect2' href='#toc2'>Description</a></h2> These functions search the available image formats to find one suitable for loading or saving a file. <p> <a href='im_open.3.html'><b>im_open(3)</a> </b> will do something similar, but that returns a descriptor to the file rather than copying to a descriptor you supply. <p> The two APIs are useful in different circumstances: <a href='im_open.3.html'><b>im_open(3)</a> </b> is good if you want to directly manipulate a file on disc, for example with the paintbox functions. On the other hand, this format API is useful for controlling how a image is unpacked, since you can specify a destination for the copy. <p> Image formats are subclasses of <b>VipsFormat</b> as outlined above. They are expected to implement at least one of the methods. They should also set values for the <b>nickname</b> and <b>description</b> members of <b>VipsObject.</b> <p> Other members are: <p> <b>is_a()</b> A function which tests whether a file is of the specified format. This is useful if you can guess a file type from the first few bytes in the file. If you leave this function NULL, vips will guess from the filename suffix for you. <p> <b>header()</b> Load only the image header, not any of the image pixels. vips will call this first on <a href='im_open.3.html'><b>im_open(3)</b></a> and delay loading pixels until asked. If you leave this NULL, vips will just use the <b>load()</b> function. <p> <b>load()</b> Load the image from the file into the IMAGE. You can leave this function NULL if you only have a <b>save()</b> method implemented. Load options may be embedded in the filename, see the loaders below. <p> <b>save()</b> Write from the IMAGE to the file in this format. You can leave this function NULL if you only have a load method implemented. Save options may be embedded in the filename, see the savers below. <p> <b>get_flags()</b> A function which examines the file and sets various flags to indicate properties of the image. The only flag implemented at the moment is <b>VIPS_FORMAT_PARTIAL</b> which may be set to indicate that the file can be read lazily. <p> <b>priority</b> sets a priority for the format. Priorities for formats default to zero: you mmay set a lower or higher number to set where in the format table your format is positioned. <p> <b>suffs</b> A NULL-terminated array of possible file-name suffixes for this format. This list is used to filter filenames when they are shown to the user, and to help select a format to sav a file as. For example, the JPEG format has the suffixes: <b>{ ".jpg", ".jpeg", ".jpe", NULL }</b> <p> <a href='vips_format_map.3.html'><b>vips_format_map(3)</b></a> maps a function over the list of available formats. See <a href='im_slist_map.3.html'><b>im_slist_map(3)</a> .</b> <p> <a href='vips_format_for_file.3.html'><b>vips_format_for_file(3)</b></a> looks at a file on disc and selects the ’best’ format to use to load that file. If no suitable format is found, it returns NULL and sets an error message. <p> <a href='vips_format_for_name.3.html'><b>vips_format_for_name(3)</b></a> looks at a filename and picks a format to use to save that file based on the file extension. If no suitable format is found, it returns NULL and sets an error message. <p> <a href='vips_format_read.3.html'><b>vips_format_read(3)</b></a> is a convenience function which copies the image from the file into the IMAGE. error, it returns non-zero and sets an error message. <p> <a href='vips_format_write.3.html'><b>vips_format_write(3)</b></a> is a convenience function which copies the image to the file in the appropriate format. On error, it returns non-zero and sets an error message. <p> <h2><a name='sect3' href='#toc3'>Supported Formats</a></h2> <p> See the following manpages for details on each of the converters and the options they implement. <p> <a href='im_analyze2vips.3.html'><b>im_analyze2vips(3)</b></a> <a href='im_csv2vips.3.html'><b>im_csv2vips(3)</b></a> <a href='im_exr2vips.3.html'><b>im_exr2vips(3)</b></a> <a href='im_jpeg2vips.3.html'><b>im_jpeg2vips(3)</b></a> <a href='im_magick2vips.3.html'><b>im_magick2vips(3)</b></a> <a href='im_png2vips.3.html'><b>im_png2vips(3)</b></a> <a href='im_ppm2vips.3.html'><b>im_ppm2vips(3)</b></a> <a href='im_tiff2vips.3.html'><b>im_tiff2vips(3)</b></a> <a href='im_vips2csv.3.html'><b>im_vips2csv(3)</b></a> <a href='im_vips2jpeg.3.html'><b>im_vips2jpeg(3)</b></a> <a href='im_vips2png.3.html'><b>im_vips2png(3)</b></a> <a href='im_vips2ppm.3.html'><b>im_vips2ppm(3)</b></a> <a href='im_vips2tiff.3.html'><b>im_vips2tiff(3)</b></a> <p> You can also load Matlab .mat files and load or save Radiance HDR files. See <a href='im_binfile.3.html'><b>im_binfile(3)</a> </b> and <a href='im_raw2vips.3.html'><b>im_raw2vips(3)</b></a> for RAW file read. <p> You can list <p>the supported formats with <p> $ vips --list classes<br> <p> look for subclasses of <b>VipsFormat.</b> <p> <h2><a name='sect4' href='#toc4'>Return Value</a></h2> The functions return 0 success and -1 on error. <h2><a name='sect5' href='#toc5'>See Also</a></h2> <a href='im_tiff2vips.3.html'>im_tiff2vips(3)</a> , <a href='im_open.3.html'>im_open(3)</a> , <a href='vips.1.html'>vips(1)</a> . <h2><a name='sect6' href='#toc6'>Author</a></h2> Jesper Friis and John Cupitt <p> <hr><p> <a name='toc'><b>Table of Contents</b></a><p> <ul> <li><a name='toc0' href='#sect0'>Name</a></li> <li><a name='toc1' href='#sect1'>Synopsis</a></li> <li><a name='toc2' href='#sect2'>Description</a></li> <li><a name='toc3' href='#sect3'>Supported Formats</a></li> <li><a name='toc4' href='#sect4'>Return Value</a></li> <li><a name='toc5' href='#sect5'>See Also</a></li> <li><a name='toc6' href='#sect6'>Author</a></li> </ul> </body> </html>