Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imagemagick: Convert to fixed height, proportional width

Using Imagemagick, I'd like to convert a batch of PNGs to a fixed height of 1080px and a proportional width. With proportional I mean this: If the original Image is scaled down 16.8% to 1080px, the width also needs to be scaled down by 16.8%.

Any way of using convert without having to calculate the exact geometry before (using identify and some bash calculation shenanigans) ?

like image 723
Christian Avatar asked Jun 07 '11 12:06

Christian


2 Answers

Try this:

convert -resize x1080 {from_path} {to_path}
like image 143
Dmitri Gudkov Avatar answered Nov 13 '22 14:11

Dmitri Gudkov


Image geometry is an option described to use with -resize

xheight Height given, width automagically selected to preserve aspect ratio.

So you only have to specify the height

like image 6
DanielB Avatar answered Nov 13 '22 14:11

DanielB