I have a collection of ~30,000 images (mostly photos) in a directory tree.
There are a few hundred images there (jpgs and pngs) that I need to square.
How to find them?
Find all images with prefix "hide" and suffix "hero" whose width is at least twice the height
What to do with them?
Add black padding on top and bottom so that they become square.
Sample image we are looking for
https://www.dropbox.com/s/ovz7fb9njwxhn ... G_hero.jpg
Sample result
https://www.dropbox.com/s/gxwl4iekksko6 ... d_hero.jpg
I've seen this http://www.imagemagick.org/Usage/thumbnails/#square
but it's still over my head and I could use your assistance.
Thank you!
Marino
Help me square some images ($100)
Re: Help me square some images ($100)
You need to specify your platform as you will need a shell or batch script and that will be the first thing you are asked; along with you IM version.
Re: Help me square some images ($100)
Centos, ImageMagick 6.8.1-0 2012-12-27 Q16
Re: Help me square some images ($100)
The following script should do the trick:
Code: Select all
#!/bin/sh
FILES=`ls /path/to/files/hide*hero.*`
for FILE in ${FILES}; do
WIDTH=`identify -format %w "$FILE"`
DOUBLE_HEIGHT=`identify -format %[fx:h*2] "$FILE"`
if [ $DOUBLE_HEIGHT -lt $WIDTH ]; then
mogrify -background black -gravity center -extent ${WIDTH}x${WIDTH} $FILE $FILE.jpg
fi
done
Re: Help me square some images ($100)
Thank you, Dirk.
Marino
Marino