Advertisement
metalx1000

Imagemagick crop images to square

Sep 1st, 2020
1,959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.26 KB | None | 0 0
  1. #!/bin/bash
  2. #crops all images to a square
  3. #set output size
  4. size="300"
  5.  
  6. for i in ../imgs/*;
  7. do
  8.   #get longest side
  9.   s="$(identify -format "%[fx:min(w,h)]x%[fx:min(w,h)]+0+0" $i)"
  10.  convert $i -gravity center -crop $s -resize $size "$(basename $i)"
  11. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement