JPG subsampling in TIFF

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

JPG subsampling in TIFF

Post 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?)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: JPG subsampling in TIFF

Post 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.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: JPG subsampling in TIFF

Post 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..
Post Reply