Resize large images (>10000 pixels)

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
ozbigben
Posts: 27
Joined: 2012-03-25T02:15:27-07:00
Authentication code: 8675308

Resize large images (>10000 pixels)

Post by ozbigben »

ImageMagick-6.7.6-Q16 Win32, XP SP3

I found an error in resizing large images when one of the image dimensions is >10,000 pixels.

Code: Select all

convert in.tif -resize 512x512^> out.jpg
Given an input image of 10192x7230px results in an image of 722x512px.
Resize the input image to 1019x723px results and you get an image of 512x363px

The error appears to be due to treating the dimensions as text once the number exceeds 10,000 (which is freaking weird) and is consistent across the batch of images I processed.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Resize large images (>10000 pixels)

Post by anthony »

In what way is it wrong?

You asked to shrink large images only (you should escape the '>' character!)
and make the shorter length 512 as per the '^' flag. (That is given dimensions are to fit inside the resulting image)

The second example looks like the '^' was not seen.

Could you be working with DOS where '^' is special in some situations?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ozbigben
Posts: 27
Joined: 2012-03-25T02:15:27-07:00
Authentication code: 8675308

Re: Resize large images (>10000 pixels)

Post by ozbigben »

anthony wrote:In what way is it wrong?
The final image should fit within 512x512px. Both source images have all dimensions bigger than this, and also have the same proportions. The output image in both cases should have been the same size but the one derived from the larger image has a height of 512px (wrong) while the smaller one has a width of 512px (correct). Of the batch of images I ran every image <10,000px resized as expected and every image >10,000px resized incorrectly.
anthony wrote:You asked to shrink large images only (you should escape the '>' character!)
That's what the "^" is for. I forgot to also mention that I'm running this via a batch file.
anthony wrote:...and make the shorter length 512 as per the '^' flag. (That is given dimensions are to fit inside the resulting image)

The second example looks like the '^' was not seen.

Could you be working with DOS where '^' is special in some situations?
The '^' is used to escape the '>' ie. my command line should be equivalent to

Code: Select all

convert in.tif -resize 512x512\> out.jpg
Referenced from: http://www.imagemagick.org/Usage/windows/#conversion and http://www.imagemagick.org/Usage/resize/#shrink

I can generate similar errors with a database if the input image height and width fields are stored as text. Calculating the dimensions of the resulting output image will produce the same results and will be "fixed" by simply changing the field type of the image dimension fields to numerical.

Using the large image from my example, calculate ratio of input:output image sizes as

maximum (height,width) / 512

Results in (7230 / 512) if the fields are text and (10192 / 512) if the fields are numbers.

[edit]It's possible that the only reason the images smaller than 10000px worked was because all dimensions were larger than 1000px. With both height and width having the same number of digits it doesn't matter whether it's treated as text or numbers. I'll investigate this further when I get home.[/edit]
ozbigben
Posts: 27
Joined: 2012-03-25T02:15:27-07:00
Authentication code: 8675308

Re: Resize large images (>10000 pixels)

Post by ozbigben »

Well now I'm confused... but happy to report that it must have been a temporary system issue.. albeit a freaking weird one. Tested on Win7, no problem. Ran the same test on the original computer via remote desktop and it worked as expected. Ran part of the original batch file and it's behaving. I'll rerun all batches again just to be sure but feel free to delete this thread.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Resize large images (>10000 pixels)

Post by anthony »

Not that '^' usage could be tricky in DOS, as it was sort of developed piecemeal with not a lot of intergration.

Hint... The way I check on exactly what a UNIX shell passes on to a program it runs is to use an echo command

For example....

Code: Select all

echo "100x100\>"
100x100>
backslash removed

Code: Select all

echo '100x100\>'
100x100\>
backslash not removed

You may need to do the equivalent test in DOS to see if IM will see the '^' or not.

You can also get C programs that you can run that can do this more thoroughly. That is by being an actual program rather than a shell (DOS) built in that may have other side effects.

Please share your findings (good and bad) here so others can benefit, and I can incorporate them into IM Examples. I am not a DOS (or windows) user, so I rely on feed back from others.

ASIDE: the above technique was used by me extensively to ensure that IMv7 script interpreter (in alpha development) acts in a similar manner to the linux BASH shell, with regards to: backslash, quotes, and line continuation; This means DOS uses can use IMv7 scripting to run imagemagick options in the same style as the rest of IM examples. (the scripting command is called "magick", so as not to conflict with the windows "convert" command).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply