Page 1 of 1

How to batch resize to a specific aspect ratio by adding white borders

Posted: 2017-01-02T17:25:03-07:00
by feelart
Hello,

I have a bunch of (scan) jpegs, which have different pixel resolutions and display ratios.
for instance 730x1080, 764x1080, 2059x2912

I which to convert all of them to A4 format, aka 210x297 in whatever sufficient dpi.
It means that some jpeg, do need some white borders on their width, or on their top&bottom borders, in order to output in A4 format.

Border(http://www.imagemagick.org/Usage/crop/#border) could do it if I indivually count for every scan, but here in a batch process I do not know which input ratio I have for each image.

Additionnaly, I wish to resize the longest side to a specific pixel size, say 1200, so that all output have same dpi.

How can I do that?

Thanks

Re: How to batch resize to a specific aspect ratio by adding white borders

Posted: 2017-01-02T17:36:35-07:00
by anthony
LOok at the examples in Thumbnails, Padding Images
http://www.imagemagick.org/Usage/thumbnails/#pad

However if you are not after a specific size just a specific ratio. That can be trickier.
See 'Squaring an image' whcih is very simular to what you are after.
http://www.imagemagick.org/Usage/thumbnails/#square
You just need to adjust the 'math' to set the width to height ratios. ;-)

Re: How to batch resize to a specific aspect ratio by adding white borders

Posted: 2017-01-02T17:42:29-07:00
by anthony
Additional...
This is also related.. Rotate with internal crop Preserving Aspect Ratio
http://www.imagemagick.org/Usage/distor ... te_methods