I want to resize an image to a max width
. So I don't care about the height of the image, but I just want to always resize it to a specific width.
I'm certain I've done this before I just can't remember how I did it now.
Seems this is the way it is done, noting that width is the first parameter.
convert -resize '100' image.png
For anyone else wondering about height, then you would do this:
convert -resize 'x100' image.png
Source: http://www.imagemagick.org/script/command-line-processing.php
Edit (Nov 2014): Note that in the latest versions of ImageMagick you can no longer use quotes around the values as per Kevin Labécot's comment.
Your question is ambiguous. Your titles asks to resize an image to a max width, but then you seem to say you want to resize the image to a specific width.
If you want to resize something to a max width of 600px (ie, any image with a width of less than 600px will be unaffected), use:
convert original_image.jpg -resize 600x\> result_image.jpg
Or, to directly modify the original image:
mogrify -resize 600x\> original_image.jpg
If you'd like max height rather than max width:
convert original_image.jpg -resize x600\> result_image.jpg
Are you just chasing the math to work out the correct aspect ratio?
$new_width = 400; // config
$image_width = 480; // loaded from image
$image_height = 786; // loaded from image
$new_height = $new_width * ($image_height / $image_width);
echo "$image_width x $image_height becomes $new_width x $new_height";
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