Search code examples
c#image-processingcompressiontifflibtiff

Can we manipulate TIFF image attributes such as rowsperstrip to achieve further compression?


Libtiff gives functions to manipulate TIFF image attributes, my code uses such functions, but I am having some issues using them. This lead me to thinking, does changing attribute values of a TIFF image really help us achieve compression? Am i right? corect me.


Solution

  • Changing attributes (aka tags) like Compression won't change compression of the image. And acting this way you can corrupt the image.

    If you are trying to change compression of the image then you should decompress it first and the compress with a new compression scheme. You will have to copy relevant tags as well.

    Take a look at source code for tiffcp utility. This utility does exactly this: it changes compression of TIFF images (besides some other things).

    EDIT:

    Other tags like RowsPerStrip, StripByteCounts, StripOffset can't be changed without corrupting image, either. You should only changes these if you are absolutely certain that values are wrong (because of broken generator or something like this) and you are trying to fix the image.