Hello!
Is there any way, with identify for example, of knowing which chroma-subsampling was used in a certain JPEG file?
Thanks.
Knowing which chroma-subsampling was used in a JPEG
Re: Knowing which chroma-subsampling was used in a JPEG
Code: Select all
identify -verbose image.jpg
...
jpeg:sampling-factor: 2x2,1x1,1x1
Or just use:
Code: Select all
identify -format "%[jpeg:sampling-factor]" image.jpg
Both commands take these factors as image attribute (could be stored in other places). So, this would be possible, too:
Code: Select all
convert rose: rose.jpg
convert rose.jpg rose.png
identify -format "%[jpeg:sampling-factor]" rose.png
Here, it's of course no real sampling-factor!

You can also use:
Code: Select all
identify -debug coder -log "%e" image.jpg
Re: Knowing which chroma-subsampling was used in a JPEG
Many thanks!
Weird as it may seem I hadn't seen the -verbose option (duh!!!) when looking at the -help output...
Weird as it may seem I hadn't seen the -verbose option (duh!!!) when looking at the -help output...

- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Knowing which chroma-subsampling was used in a JPEG
see http://www.imagemagick.org/Usage/basics/#controls and http://www.imagemagick.org/script/identify.php
also see
YCbCrSubSampling
from EXIF tags at http://www.imagemagick.org/script/escape.php
convert image -format "%[EXIF:YCbCrSubSampling]" info:
also see
YCbCrSubSampling
from EXIF tags at http://www.imagemagick.org/script/escape.php
convert image -format "%[EXIF:YCbCrSubSampling]" info:
Re: Knowing which chroma-subsampling was used in a JPEG
Though this tag is usually for TIFF files - not for JPG files.fmw42 wrote:YCbCrSubSampling
from EXIF tags at http://www.imagemagick.org/script/escape.php
convert image -format "%[EXIF:YCbCrSubSampling]" info:
Regarding TIFF:
1) The above code doesn't work (even for 'JPG in TIFF' files that have this tag). IM can't output these EXIF tags in TIFF directly.
2) IM translates the info from the EXIF tags in TIFF partly into 'tiff:', 'jpeg:' or 'photoshop:' attributes. So, one can retrieve the info from the YCbCrSubsampling tag again with "identify -format "%[jpeg:sampling-factor]" image.tif". For example, if the stored values in the tag are "2 2", then IM displays that as "jpeg:sampling-factor: 2x2".
3) But even this info will be wrong for most of the 'JPG in TIFF' files that IM creates. Most of these files can't use subsampling anyway (the sampling-factor will be just 1x1). See my report here.
So, sadly there is no easy way to retrieve the real sampling-factor for JPG compression in TIFF.