-resize> faulty behavior
Posted: 2013-12-03T23:19:03-07:00
The resize function shows unexpected behavior in the following case:
The following command should resize an image to fit within 1200x1200, keep the aspect ratio and also ignore images that are smaller (so only downsize, hence the ^>, ^ since I work on a Windows machine).
My source image is 1920x1080, I would expect it to be turned into 1200x675, but instead it stays the original resolution. After some testing I found that the reason it does this is because it tries to keep the aspect ratio, so because 1080 is within 1200, it ignores the 1920 size.
I ran the command again without the ^> part.
In this case it is processed correctly and the target image is 1200x675. However, since I removed the ^> part it will now also start to upscale images that are smaller than 1200x1200.
So in short, the setting used to force "downscale only", has the unexpected side-effect that it will also keep the aspect ratio by taking the smallest side and use that to fit the bounding box of 1200x1200, instead of the normal behavior where it would try to fit the largest side of the image and make sure that that fits within the bounding box of 1200x1200.
I would consider this a bug, but maybe I don't understand the settings of -resize in enough detail.
The following command should resize an image to fit within 1200x1200, keep the aspect ratio and also ignore images that are smaller (so only downsize, hence the ^>, ^ since I work on a Windows machine).
Code: Select all
convert -resize 1200x1200^> source.jpg target.jpg
I ran the command again without the ^> part.
Code: Select all
convert -resize 1200x1200 source.jpg target.jpg
So in short, the setting used to force "downscale only", has the unexpected side-effect that it will also keep the aspect ratio by taking the smallest side and use that to fit the bounding box of 1200x1200, instead of the normal behavior where it would try to fit the largest side of the image and make sure that that fits within the bounding box of 1200x1200.
I would consider this a bug, but maybe I don't understand the settings of -resize in enough detail.