jpeg:extent Gross Misestimation

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
Posts: 1
Joined: 2014-03-12T14:01:44-07:00
Authentication code: 6789

jpeg:extent Gross Misestimation

Post by bugreporter »


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: ... C3%B1a.jpg, also hosted at (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.

User avatar
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: jpeg:extent Gross Misestimation

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