I'd like to check and see if all images in a directory are landscape or portrait, and them to portrait if they are in landscape. After rotating, I want to resize the images so that it is a particular resolution (118 dots per cm) and horizontal dimension (9cm).
In summary:
- All images in portrait
- Resolution of 118 dots per cm
- 9cm Horizontal dimension
I know identify can pull the dimensions, but I'm not sure how to pull the individual height/width values.
Basically, I'd like to do this:
FILES=/path/to/*
for i in $FILES
identify -format "%f,%w,%h"
do
if [%w -gt %h]
then
convert -rotate 90 $i
mogrify -resize -density ?x? -resolution? -PixelsPerCm $i $i_resized.jpg
done
Ultimately, I would like to tile these to a 1m x any lenth document for printing from a plotter. Thanks!