sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Enhancement: expose TIFF compression in metadata

Open joesong168 opened this issue 1 year ago • 3 comments

Question about an existing feature

metadata didn't return the image format for pyramid tif

What are you trying to achieve?

show the format of tile in metadata

joesong168 avatar May 12 '23 13:05 joesong168

Please can you provide more details. Are you perhaps referring to the compression used within a TIFF image? A sample image and the expected output would be useful.

lovell avatar May 12 '23 13:05 lovell

As tiff file has the option to contain tile in format like none, jpeg, deflate, it would be helpful to know the details before further actions, like whether to compress it again. Currently metadata function only return the format as 'tiff', I would suggest to add field called tile-format to indicate the format of tile.

Here is an example image file: https://viewers.etu.wiki/cfa461d04332d3648b44a18854a64687.tif

joesong168 avatar May 12 '23 15:05 joesong168

Thanks, we'd need to expose this information via libvips first.

The underlying TIFF "compression" value is an integer - see https://gitlab.com/libtiff/libtiff/-/blob/master/libtiff/tiff.h#L182-218

We'd probably want to map these to the relevant VipsForeignTiffCompression values - see https://www.libvips.org/API/current/VipsForeignSave.html#VipsForeignTiffCompression

The logic would probably live in/near rtiff_set_header() - see https://github.com/libvips/libvips/blob/master/libvips/foreign/tiff2vips.c#L1665

A PR to implement this in libvips would be welcome, if you're able.

lovell avatar May 12 '23 16:05 lovell