Fractional sampling error with -define jpeg:size
Posted: 2014-10-25T13:41:11-07:00
On the file https://upload.wikimedia.org/wikipedia/ ... 508102.jpg which has a weird YCbCr subsampling value of "2 3", the following:
convert -define 'jpeg:size=118x70' End-of-the-world-Stephen-Hawking-god-particle-Higgs-boson-508102.jpg out.jpg
fails with the error:
convert: Fractional sampling not implemented yet `End-of-the-world-Stephen-Hawking-god-particle-Higgs-boson-508102.jpg' @ error/jpeg.c/JPEGErrorHandler/321.
This appears to be due to the combination of the -define 'jpeg:size=118x70' telling libjpeg to scale the image by 1/2, while at the same time the YCbCr subsampling telling it to upscale the vertical dimension by 3, resulting in a combined vertical scaling by 3/2, which is fractional, triggering the error.
I'm not sure who is at fault here, whether the image is just totally broken for having that subsampling, or if image magick shouldn't be specifying a scale factor to libjpeg if it would cause fractional subsampling, or if libjpeg's jpeg_calc_output_dimensions() should be checking for this situation when verifying jpeg_info->scale_denom is valid. (Thus I apologize if this isn't really an image magick bug)
---
bawolff@Bawolff-L:~$ convert --version
Version: ImageMagick 6.8.9-3 Q16 i686 2014-06-17 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib fftw fontconfig freetype jbig jng jpeg lcms lzma pangocairo png tiff x xml zlib
Bug originally at: https://bugzilla.wikimedia.org/show_bug.cgi?id=72511
Thanks.
convert -define 'jpeg:size=118x70' End-of-the-world-Stephen-Hawking-god-particle-Higgs-boson-508102.jpg out.jpg
fails with the error:
convert: Fractional sampling not implemented yet `End-of-the-world-Stephen-Hawking-god-particle-Higgs-boson-508102.jpg' @ error/jpeg.c/JPEGErrorHandler/321.
This appears to be due to the combination of the -define 'jpeg:size=118x70' telling libjpeg to scale the image by 1/2, while at the same time the YCbCr subsampling telling it to upscale the vertical dimension by 3, resulting in a combined vertical scaling by 3/2, which is fractional, triggering the error.
I'm not sure who is at fault here, whether the image is just totally broken for having that subsampling, or if image magick shouldn't be specifying a scale factor to libjpeg if it would cause fractional subsampling, or if libjpeg's jpeg_calc_output_dimensions() should be checking for this situation when verifying jpeg_info->scale_denom is valid. (Thus I apologize if this isn't really an image magick bug)
---
bawolff@Bawolff-L:~$ convert --version
Version: ImageMagick 6.8.9-3 Q16 i686 2014-06-17 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib fftw fontconfig freetype jbig jng jpeg lcms lzma pangocairo png tiff x xml zlib
Bug originally at: https://bugzilla.wikimedia.org/show_bug.cgi?id=72511
Thanks.