Pixel Rounding On -thumbnail convert

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
gotskill10
Posts: 17
Joined: 2007-06-02T14:01:34-07:00

Pixel Rounding On -thumbnail convert

Post by gotskill10 »

The behavior of the pixel rounding on convert is somewhat counter intuitive to me.

I have a jpg file that is 300x203. I convert it using -thumbnail and preserving the aspect ratio. It gives me a file dimensions of 100x68.

The 68 comes from 67.666666 rounded up.

Shouldnt it be rounding down to 67 since the information for that pixel doesn't completely exist? Or does it just do a normal round and hope for the best?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Pixel Rounding On -thumbnail convert

Post by anthony »

ImageMagick rounds to the nearest integer, excluding zero (that was a bug that was specifically fixed).

The information however does exist! Once the output image is known, the original image data is 'filtered' to fit into the new image size. Actually this is a very tricky matter, and last year I went though a redevelopment of that whole process. Check out the Reszie images pages in IM examples for more detail than you probably want to know!

If you don't want to round the image to integer units, but do exact image scale to partially fill pixels, then have a look at SRT distortion for resizing images. This will NOT round the resizing to an interger size, though the final image may be enlarge the image slightly to ensure any and all 'partial pixels' are included in the resulting image. This can of course generate 'fuzzy' borders :-)

Distort Resizing...
http://www.imagemagick.org/Usage/resize/#distort
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply