Set transparent background using ImageMagick and commandline prompt

Israel picture Israel · Feb 6, 2012 · Viewed 117.3k times · Source

Suppose you have any image (PNG or JPG). This image has a white background and I need to make this background transparent.

I have tried with these examples:

  • convert original.png -background none transparent.png
  • convert original.png -background white -flatten -alpha off transparent.png

but with no desirable results.

How can I make it?

IMPORTANT: Using convert command-line.

Answer

Rijk picture Rijk · Jun 20, 2012

I am using ImageMagick 6.6.9-7 on Ubuntu 12.04.
What worked for me was the following:

convert test.png -transparent white transparent.png

That changed all the white in the test.png to transparent.