2008/6/16 Ole Laursen <[log in to unmask]>:
> Which brings me to the point - with TIFF it's easy to set the DPI/PPI
> setting when you save the file. This makes the printing business happy since
> they can just press a button. But how do I do set the DPI for JPEGs?
VIPS does this for you. Just set the xres/yres fields in the vips
header, and it'll use them to set the EXIF data in the jpeg for you
when it saves. It'll set the tiff resolution in the same way.
You can see the code vips uses here
http://vips.svn.sourceforge.net/viewvc/vips/vips7/branches/vips-7.14/libsrc/conversion/im_vips2jpeg.c?view=markup
Search for set_exif_resolution()
> by EXIF, but I can't really find any documentation about it and the metadata
> stuff in VIPS doesn't appear to be available in the Python interface (?)
> which makes testing with the rest of the pipeline I've built a bit difficult.
There are some copy/set operators:
im_copy_morph - copy image, setting pixel layout
im_copy_swap - copy image, swapping byte order
im_copy_set - copy image, setting informational fields
im_copy_set_meta - copy image, setting a meta field
So something like
fred2 = fred.copy_set (fred.Type(), xres, yres, 0, 0)
> Note that this is just the DPI setting used for deriving the physical
> dimensions of the image. I've got the actual image resolution in absolute
> pixels totally under control. :-)
Good stuff!
J
|