简体   繁体   中英

How to remove an image's solid background using ImageMagick convert command

I'm finding a way to make the solid background of an image become as transparent as possible (with little halo). ImageMagick is a powerful tool however it's not easy to use. I tried one command "convert image.jpg -bordercolor white -border 1x1 -alpha set -channel RGBA -fuzz 20% -fill none -floodfill +0+0 white -shave 1x1 image.png", which works kinda well. However, this requires me to know the exact color of the solid background while I need something to work with any background color. Anyone could help me with this? Th

As a heuristic, you could ask for the color of the pixels at the corners (http://studio.imagemagick.org/pipermail/magick-users/2005-March/015034.html) and then see which color is used the most. Not exactly fool-proof, though...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM