Using ImageMagick, how can I resize an image to have a minimum:
and also have a maximum:
UPDATE:
In case it helps, here's a further explanation of what I'm experiencing.
I have a buch of images with all different ratio dimensions. Some images have 1:5 height/width ratios. Some have 5:1 height/width ratios. So that I want to do is set that a minimum height/width size for the image but also don't want the image size to be larger than a particular size.
If I need to apply white padding to an image to make it fit within my constraint so that I don't have to distort the image, I'd like to do so.
I can't entirely get my head around your requirement, but I think this should be possible if you run IM twice.
See the manual on geometry options:
A combination of
widthxheight> Change as per widthxheight but only if an image dimension exceeds a specified dimension.
and
widthxheight^ Minimum values of width and height given, aspect ratio preserved.
might do the trick. However, for images whose aspect ratio lies outside your requirements, I think you will have to create a fixed size canvas in IM, fill it with some colour, insert the image, and do a trim()
on it... Probably not possible in one go, though.
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