Friday, 23 December 2011

new file format system

vips8 slowly creeps closer. A new system for loading and saving images has just arrived.

You used to specify file formats and give them options like this:
$ vips im_vips2tiff myfile.v newfile.tiff:jpeg
meaning load the file myfile.v, then write it to newfile.tiff in TIFF format with jpeg compression.

The vips8 equivalent is called tiffsave. If you run it with no arguments you get a nice help display:
$ vips tiffsave
usage:
   tiffsave in filename
where:
   in           - Image to save, input VipsImage
   filename     - Filename to save to, input gchararray
optional arguments:
   compression  - Compression for this file, input VipsTiffCompression
   Q            - Q factor, input gint
   predictor    - Compression prediction, input VipsTiffPredictor
   profile      - ICC profile to embed, input gchararray
   tile         - Write a tiled tiff, input gboolean
   tile-width   - Tile width in pixels, input gint
   tile-height  - Tile height in pixels, input gint
   pyramid      - Write a pyramidal tiff, input gboolean
   squash       - Squash images down to 1 bit, input gboolean
   resunit      - Resolution unit, input VipsTiffResunit
   bigtiff      - Write a bigtiff image, input gboolean
 and you can do the equivalent of the old vips7 command above like this:
$ vips tiffsave myfile.v newfile.tiff --compression jpeg
You can also embed options in the filename using the standard vips8 syntax. For example:
$ vips invert fred.jpg jim.tif{compression=jpeg}
Which will load fred.jpg, invert it, then save as a jpeg-compressed tiff.

The old vips7 system is still there and working, though it's now just a thin skin over the new system, so it's fully backwards-compatible.

There's a very similar C API and it's also easy expressed in Python and C++. It's also easy to add support for new formats. We have preliminary documentation and source code available.


No comments:

Post a Comment