Squaring Images with ImageMagick

It took me a while to find a good utility to square images and make them a certain size. The results come from this confusing documentation page for Image Magic.


convert -define jpeg:size=510x510 Test1.jpg -thumbnail "510x510>" -background white -gravity center -extent "510x510" testResult.jpg

Of course you change the sizes and the background color. The page above also show you how to crop the picture if desired to fit the square image (rather than padding with the background color).

The following command (mogrify) does the exact same for every file in the current directory, and outputs to another directory specified by the -path parameter. (reference: mogrify)


mogrify -define jpeg:size=510x510 -thumbnail "510x510>" -background white -gravity center -extent "510x510" -path ../ImageOutputDir *.jpg

Note: When installing on Windows, be sure to check the box to the left of “Install legacy utilities” so it will install the convert.exe program.

See also: Photo.StackExchange/questions/27137K

See also: Downloads for ImageMagick.

Uncategorized  

Leave a Reply