Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to cut transparent part from photo with command or shell script

I am having trouble to cut photos in the command line. I need to cut transparent part of a photo and save with command line or shell script Thanks beforehand. If I could do it I would apply it for 4000 photos and it would be a great help More clear explanation what I want to do I have a png picture like this enter image description here

I want to have an image like this

enter image description here

I could make the image transparent only and is there any way to cut bottom transparent part from a png file

Beforehand thank you very much

like image 764
Max Avatar asked Oct 16 '18 06:10

Max


1 Answers

It's hard without seeing your images, but you can try with ImageMagick as follows:

convert input.png -trim +repage output.png

and see if that works. If it nearly works, try:

convert input.png -fuzz 25% -trim +repage output.png

If it works, make a backup and then do them all with GNU Parallel:

find . -name \*.png -print0 | parallel -0 mogrify -trim +repage {}
like image 122
Mark Setchell Avatar answered Oct 21 '22 11:10

Mark Setchell