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?
Pixel Rounding On -thumbnail convert
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Pixel Rounding On -thumbnail convert
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
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/
https://imagemagick.org/Usage/