TIFF predictor
Posted: 2010-08-24T17:37:44-07:00
Is there a possiblity to specify a predictor/filter value for TIFF compressions in ImageMagick? The (horizontal) predictor is already used by IM - but it's hardcoded and gets used only with certain TIFF files.
A possibility with a "-define" option would be ideal. (Or is there already such an option? I didn't see one, but maybe I overlooked something..) The legal values for TIFFTAG_PREDICTOR in libtiff would be 1 to 3, I think (1=no predictor, 2=horizontal predictor, 3=predictor for float).
A second possibility would be to at least hardcode the horizontal predictor with some more TIFF formats (within the ZIP and LZW compression). The current ZIP compression code in coders/tiff.c looks like that:
So, the compression level (TIFFTAG_ZIPQUALITY) is adjustable by the user (with "-quality"). But not the predictor. It gets used, but only with RGB and some BiLevel (min-is-black) images. IMHO, it should also be used for CMYK images.
With large CMYK TIFFs, the filesize difference would be quite huge, if the predictor could be used (of course not with all, but with most of the files, I think).
One can use a compression with predictor with libtiff itself. But a possibility within ImageMagick would be really great!
A possibility with a "-define" option would be ideal. (Or is there already such an option? I didn't see one, but maybe I overlooked something..) The legal values for TIFFTAG_PREDICTOR in libtiff would be 1 to 3, I think (1=no predictor, 2=horizontal predictor, 3=predictor for float).
A second possibility would be to at least hardcode the horizontal predictor with some more TIFF formats (within the ZIP and LZW compression). The current ZIP compression code in coders/tiff.c looks like that:
Code: Select all
case COMPRESSION_ADOBE_DEFLATE:
{
rows_per_strip=(uint32) image->rows;
(void) TIFFGetFieldDefaulted(tiff,TIFFTAG_BITSPERSAMPLE,
&bits_per_sample);
if (((photometric == PHOTOMETRIC_RGB) ||
(photometric == PHOTOMETRIC_MINISBLACK)) &&
((bits_per_sample == 8) || (bits_per_sample == 16)))
(void) TIFFSetField(tiff,TIFFTAG_PREDICTOR,2);
(void) TIFFSetField(tiff,TIFFTAG_ZIPQUALITY,(long) (
image_info->quality == UndefinedCompressionQuality ? 7 :
MagickMin((ssize_t) image_info->quality/10,9)));
break;
}
With large CMYK TIFFs, the filesize difference would be quite huge, if the predictor could be used (of course not with all, but with most of the files, I think).
One can use a compression with predictor with libtiff itself. But a possibility within ImageMagick would be really great!