Fractional sampling error with -define jpeg:size

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
bawolff
Posts: 2
Joined: 2014-06-07T11:21:20-07:00
Authentication code: 6789

Fractional sampling error with -define jpeg:size

Post by bawolff »

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

Re: Fractional sampling error with -define jpeg:size

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.9-10 Beta, available by sometime tomorrow. Thanks.
kelson
Posts: 1
Joined: 2014-10-27T04:52:09-07:00
Authentication code: 6789

Re: Fractional sampling error with -define jpeg:size

Post by kelson »

I have tested it. Is this the correct behaviour?
$ /usr/local/bin/convert -define 'jpeg:size=118x70' in.jpg out.jpg
convert: no decode delegate for this image format `JPEG' @ error/constitute.c/ReadImage/501.
convert: no images defined `out.jpg' @ error/convert.c/ConvertImageCommand/3210.
Post Reply