I'm using ImageMagick's convert tool to generate image thumbnails for a web application. I'm using notation like so: 600x600>
The images are indeed scaled to 600px wide/tall (depending on the longer side) and proportions are properly maintained, however images less than 600px in either direction are scaled up — this behavior is not desired. Is there a way to prevent convert from scaling images up if the destination dimensions both exceed the original image size?
convert input.png -resize 600x600\> output.png
does indeed work on my installation of ImageMagick. I would double check that the >
is being escaped properly and that my version of ImageMagick is recent.
Look at the widthxheight>
syntax
widthxheight>
Change as per widthxheight but only if an image dimension exceeds a specified dimension.
Examples:
[/tmp]# identify -format "%wx%h" test.gif
172x66
[/tmp]# convert test.gif -resize '1000x1000>' test2.gif && identify -format "%wx%h" test2.gif
172x66
[/tmp]# convert test.gif -resize '10x10>' test3.gif && identify -format "%wx%h" test3.gif
10x4
[/tmp]# convert test.gif -resize '100x100>' test4.gif && identify -format "%wx%h" test4.gif
100x38
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With