Given the popularity of my post about making transparent PNG images with the Gimp, I should share a recent discovery: If you know the exact color you want to make transparent, you can do it from the command line.
What you need is the ImageMagick package, picture manipulation software that's available for all major Linux distributions, Windows, and Mac OS X (through MacPorts). If none of those work for you, you can also compile the source code.
Specifically, you need the convert command line tool. The syntax is:
convert -transparent color original_picture.png picture_with_transparent_background.png
and you can covert from png to gif, or visa versa, with the same command.
An example: here's the good ol' pengjay, with a horrid green (#00FF00) background:
Since we know the background color is #00FF00, we can pipe it through convert:
convert -transparent #00FF00 pengjay_green.png pengjay_transparent.png
and we get this:
Note that if you don't know the color, you're better off using the GIMP.
3 comments:
Can you set it to anything other than full transparency? What if I want the alpha channel to be 127?
$ man convert
doesn't list that as an option. Looking at display, the main program in the ImageMagick package, doesn't seem to have that option. For this you need something like the Gimp.
thank you sharing!
Melbourne SEO Services
Post a Comment