Page 1 of 1

Keeping an image squared

Posted: 2015-10-05T09:04:32-07:00
by thes4s67
Hi everyone. I am using imagemagick to batch trim a set of images to remove whitespace with the following command:

Code: Select all

mogrify -trim -fuzz 5 *.jpg
This works fine however how do I get the output image size to be squared? The images vary so there can't be a set squared size. I also saw this viewtopic.php?t=10419 which is quite similar to my request but I can't seem to figure out how to use those commands in addition to my command.

Re: Keeping an image squared

Posted: 2015-10-05T09:22:43-07:00
by snibgo
"-trim" will create a rectangular image. You want to make this square. How? You can crop it with "-crop". Or add transparent portions to make it square with "-background None -extent 200x200". In either case, it's easiest with two commands: "identify" to get the max or min dimension, then "convert" to crop or extent.

The third method, which you probably don't want, is to resize, changing the aspect ratio.

Re: Keeping an image squared

Posted: 2015-10-05T10:24:42-07:00
by fmw42