Help me square some images ($100)

Do you need consulting from ImageMagick experts and are willing to pay for their expertise? Or are you well versed in ImageMagick and offer paid consulting? If so, post here otherwise post elsewhere for free assistance.
Post Reply
mpascal
Posts: 3
Joined: 2014-04-13T17:09:07-07:00
Authentication code: 6789

Help me square some images ($100)

Post by mpascal »

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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Help me square some images ($100)

Post by Bonzo »

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.
mpascal
Posts: 3
Joined: 2014-04-13T17:09:07-07:00
Authentication code: 6789

Re: Help me square some images ($100)

Post by mpascal »

Centos, ImageMagick 6.8.1-0 2012-12-27 Q16
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Help me square some images ($100)

Post by dlemstra »

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
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
mpascal
Posts: 3
Joined: 2014-04-13T17:09:07-07:00
Authentication code: 6789

Re: Help me square some images ($100)

Post by mpascal »

Thank you, Dirk.
Marino
Post Reply