I'd like to crop them all to square, from the center, based on the shortest out of width and height.
In math terms I think of it like this: (Math.min(width, height)) x (Math.min(width,height))
For example:
500x1000 > crops to 500x500
1000x500 > crops to 500x500
500x500 > either goes unprocessed, or is cropped to 500x500
I've done a ton of reading and searching but I can't figure out how to reference the image width and height in a single-line command (Mac terminal).
I tried referencing %w and %h in -crop but can't get it to compare. I thought a ternary like this might work, but no luck:
Code: Select all
mogrify -gravity Center -crop "((%w>%h)?%h:%w)"x"((%w>%h)?%h:%w)"+0+0 +repage *.jpg