Reputation: 1581
The following code resizes an image so that its width is 200 and its height is whatever... How would I do it so that the height was 200 and the width was whatever...
$command = MAGICK_PATH."convert ".$filename." -resize 200 ".$filename; exec($command);
Kind regards J
Upvotes: 5
Views: 4784
Reputation: 3455
You can get width and height of the input image and then convert it. I'm not familiar with PHP so I'll post code for bash.
To change size of image to 500x200:
convert "$filename" -resize 500x200 "$filename"
To change size, while keep width or height old:
width=$(identify -format "%w" "$filename")
height=$(identify -format "%h" "$filename")
convert "$filename" -resize "200x$height" "$filename"
Note: instead of using
convert "$filename" [opts] "$filename"
it's better to use
mogrify "filename"
Upvotes: 0