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 wid开发者_如何学Pythonth 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) ?
Try this:
convert -resize x1080 {from_path} {to_path}
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
There is one additional example. give it some values to the resize parameters and it'll automatically resize your image. Plus you can chose other parameters (gravity center or crop etc.).
convert image_example: \
-resize x160 -resize '160x<' -resize 50% \
-gravity center -crop 80x80+0+0 +repage image_example.jpg
Cheers
精彩评论