Advertisement


What's the easiest way to convert a .jpg image with white background into .png with alpha channel?


Question

example .jpg:

enter image description here

Ideal .png result:

enter image description here

2013/09/13
1
5
9/13/2013 7:02:00 PM

Accepted Answer

Command line is quicker. Install Imagemagick.

One file:

convert -transparent white whatever.jpg whatever.png

More files:

Put together a bash script file:

for img in *.jpg; do
    filename=${img%.*}
convert -transparent white "$filename.jpg" "$filename.png"
done

Run it and then you will be done. Note that the above will add transparency to everything that is white 'FFFFFF' including any pixels of that colour inside your image. "topLeftPixel" can be used instead of "white" for autodecting background colour.

If the white pixels in image problem is a problem then you can do Photoshop batch. Layer mask is better than 'delete'-clearing the white pixels as you do not actually alter the RGB layers.

2013/09/13
5
9/13/2013 7:00:00 PM

If you use GIMP, I can suggest this tutorial: Perfect masking using a highpass guide. I had very good results with complex images by following it.

2011/06/20