bash

Bash, c++, Snapfish: Batch add borders to images to make-up the 4R ratio

Programming: [more]Programming: [more]

Today I used a couple of bash commands, a small C++ program, and ImageMagick to add borders to images to get them into the 3:2 ratio of 4R. I need them at this size because I don't want them auto-cropped, and I want them photo printed (via snapfish).

All my images are in one directory, and they're all jpgs (with extension .jpg). They're mostly different sizes and shapes, portrait and landscape.

The identify command from ImageMagick lets us query the resolution of the image, and writes the result to stdout:

identify image.jpg

results in:

image.jpg JPEG 1224x1632 1224x1632+0+0 DirectClass 8-bit 610.512kb

being printed in the shell.

 

We need just the name, and the resolution, and we need this for all images in the directory:

Syndicate content