Search code examples
imagebackgroundpngtransparent

Need a tool to set multiple image backgrounds to transparent


I'm searching for a software/tool to set the image background (black) to transparent.

I want to to remove all the black and make the image transparent.

All the images are .PNG and I have around 191 hence why I need a tool to do multiple images otherwise it could take me a very long time.


Solution

  • Use either graphicsmagick or imagemagick mogrify tool with the -transparent black option. When I ran it on your single sample image it looked like this:

    gm mogrify -transparent black 'sprite sheet 4.png' 
    

    To do a few hundred of these, you'd use it like this:

    for f in *.png ; do gm mogrify -transparent black "$f" ; done
    

    Be sure to work on copies of the files -- mogrify modifies files "in place".