Page 1 of 1

JPG subsampling in TIFF

Posted: 2010-09-16T07:02:12-07:00
by Drarakel
I think, 'normal RGB' as JPG in TIFF doesn't use subsampling at all (correct me if I'm wrong). But the subsampling can still be set in ImageMagick and a redundant YCbCrSubSampling tag is written:

Code: Select all

convert logo: -compress jpeg logo_rgb.tif
convert logo: -compress jpeg -sampling-factor 10x1 logo_rgb2.tif
I rather use ExifTool this time (to show that the false subsampling values are not written as comment or something like that, but as real YCbCrSubSampling tag):
exiftool -S -YCbCrSubSampling logo_rgb.tif
YCbCrSubSampling: YCbCr4:2:0 (2 2)
exiftool -S -YCbCrSubSampling logo_rgb2.tif
YCbCrSubSampling: Unknown (10 1)

Contrary to that, when the JPG in TIFF is written as YCbCr, subsampling theoretically should be possible. But here, the subsampling value (and the value for the YCbCrSubSampling tag) is hardcoded to 1x1:

Code: Select all

convert logo: -colorspace YCbCr -compress jpeg logo_ycbcr.tif
exiftool -S -YCbCrSubSampling logo_ycbcr.tif
YCbCrSubSampling: YCbCr4:4:4 (1 1)

With CMYK and grayscale colorspaces, the real subsampling is again set to 1x1. (For grayscale, a different subsampling value would be useless anyway.) But a YCbCrSubSampling tag is written - always with the default 2x2 subsampling value:

Code: Select all

convert logo: -colorspace cmyk -compress jpeg logo_cmyk.tif
convert logo: -colorspace gray -compress jpeg logo_gray.tif
exiftool -S -YCbCrSubSampling logo_cmyk.tif
YCbCrSubSampling: YCbCr4:2:0 (2 2)
exiftool -S -YCbCrSubSampling logo_gray.tif
YCbCrSubSampling: YCbCr4:2:0 (2 2)

So.. Perhaps the YCbCrSubSampling tag for JPG in TIFF should be omitted if the colorspace is not YCbCr? (And maybe other sampling-factors than 1x1 could be allowed for the YCbCr colorspace?)

Re: JPG subsampling in TIFF

Posted: 2010-09-16T12:12:54-07:00
by magick
We can reproduce the problem you reported and have a patch in ImageMagick 6.6.4-3 Beta available by sometime tomorrow. Thanks.

Re: JPG subsampling in TIFF

Posted: 2010-09-18T20:44:28-07:00
by Drarakel
OK. With IM v6.6.4-4, such strange YCbCrSubSampling tags are not possible anymore:
Drarakel wrote:exiftool -S -YCbCrSubSampling logo_rgb2.tif
YCbCrSubSampling: Unknown (10 1)
Instead, the tags are now also hardcoded to 2x2 (for RGB JPG in TIFF). So, it's a bit better now. Thanks!

Though I still think that the YCbCrSubSampling tag should be omitted for JPG in TIFF if the photometric value is RGB, CMYK or BlackIsZero/WhiteIsZero. Or the tag should be at least hardcoded to 1x1 - as that's the real 'subsampling factor' for these colorspaces in TIFF.
But there are surely more important things than this..