Page 1 of 1

jpeg:extent Gross Misestimation

Posted: 2014-03-12T14:04:45-07:00
by bugreporter
Hi,

I am writing to report an issue observed in both 6.8.8-7 and SVN head (as of 3/11/2014).

The 'jpeg:extent' function exhibits counterintuitive (and possibly errant) behavior on some large and "visually intricate" images. The output file that results may be much greater than was specified by 'jpeg:extent', and even greater than the input image.

To reproduce:

1) Use the image at:
http://upload.wikimedia.org/wikipedia/c ... C3%B1a.jpg, also hosted at http://imgur.com/FhlFZWS (sha1 39d47b7f6281bae66970ca22918f80bb8f4d3cf9)

2) Notice it has file size 4496637 and dimensions 4820x3216.

3) Run this command
ImageMagick-6.8.8-7/utilities/convert <source_file> -resize 2560x2560\^\> -define "jpeg:extent=800KB" <destination_file>

4) Notice the result has been scaled down correctly to dimensions 3837x2560, but has file size 6230201, much greater than the specified 800KB, and even larger than the original.

5) Perform the same resize, and specify a quality factor of 5 rather than 'jpeg:extent'.
ImageMagick-6.8.8-7/utilities/convert <source_file> -resize 2560x2560\^\> -quality 5 <destination_file>

6) Notice the result has been scaled down correctly, and fits within the original file size constraints. (Desired behavior)

Ideally it should abort with error if unable to achieve the specified file size, or at least get as close as possible.

Thanks!

Re: jpeg:extent Gross Misestimation

Posted: 2014-03-12T14:21:57-07:00
by magick
The source image quality is overriding the JPEG extent. We'll fix that in ImageMagick 6.8.8-9 Beta by sometime tomorrow. In the mean-time use this command:
  • convert <source_file> -quality 0 -resize 2560x2560\^\> -define "jpeg:extent=800KB" <destination_file>