Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Imagemagick, how do I crop out the white background?

Let's say I have a directory full of flags (200 or so). Each flag has this border... 12px up and down and 1px left and rigtht.... like so:

enter image description here

How can I use imagemagick to like... crop every single .PNG image from 64x64 to 60x40

like image 329
test Avatar asked Dec 26 '22 12:12

test


1 Answers

You have the automatic crop: mogrify -trim flag.png. If it does not do the exact magic you want, use crop: mogrify -crop 60x40+2+12 flag.png (That is 2 pixels left).

like image 183
kmkaplan Avatar answered Jan 21 '23 10:01

kmkaplan