Set transparent background using ImageMagick and commandline prompt

alpha-transparencyimagemagickpng

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.

Best Answer

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.