How to make a jpeg image background transparent in Photoshop
To start with - I have little experience using Photoshop so I undertook a little
project to make the background transparent in a JPEG image. I figured I would kill
two birds with one stone - teach myself some Photoshop and to get the image results
I wanted, ie , a transparent background. Here is the image I started with - see below:
Steps to make the white background transparent:
1. Open Photoshop (my version is CS5) and open the image using "File -> Open" and to be on
the safe side save the image with a different name, ie, use the "Save As" option.
This way you will have saved the original image in case of a screw up.
2. Now the image will appear in the middle of the Photoshop workspace and the layer palette
should look like this:
3. Note from the above image that the layer is named "background". Since this is the
background layer one cannot just cut out the white background. So click on the
"layer" tab and then "New -> Layer From Background.." and get dialog box that says
"New Layer" with Name: Layer 0 - just click okay to accept this new layer name.
You should get the Layer Palette that looks like the one below:
4. Now you can use the lasso tool or the magic lasso tool. So with my trusty mouse
in hand I used the magic lasso and tried to cut out the white background. Man, am I
spastic. I tried to remove the white background in steps. I started in the upper left hand
side of the image and once the selected area is fully closed - all you have to do is
press the "Del" key. Now you should see a checked pattern which represents this area is
transparent. After a lot of experimenting with the magic lasso tool, I finally got the
image below - man do I stink at this - look at all the residual white spaces I left:
By the way - you have to save the image as a GIF file as JPEG images do not support
5. I now used lasso tool ( not the magic one ) to clean up the white spaces. I then got
6. This still sucks - so I decided to try my newly acquired paper graphing tablet. This is
made by ACECAD model DigiMemo L2/A402. I setup the tablet so I could use the pen like my
mouse. I have much better drawing control with a pen than I do using a mouse.
The image below shows the result of my clean up using the drawing tablet.
7. Although the image still shows some slight imperfections ( a few white spots ) I think using
the graphic tablet is definitely superior than using a mouse. I am way too spastic with the
mouse. With a little practice I think I will always use the tablet and pen for this kind of
precision control. In fact, if I practice with the pen and the magic lasso too, I think I would
get satisfactory results on the first pass. By the way, to use the tablet pen the tablet is
plugged into a USB port ( do not press the power on button ). The pad is detected by windows
and then you need to open the "ACECAD DigiMemo Manager" and select "Tools" and make sure "Pen"
is selected - this allows you to use the pen like your mouse - with much better control.
You can see the model I used - see below:
The image now looks pretty good
by reducing the width and height
Okay let's compare mouse vs. pen to create a signature.
I used microsoft's paint program to do this
See image below of signature using a mouse
and this image below using the digimemo pen
By the way there is another tool one can use to make the background transparent. In photoshop
right click on the eraser tool and select the "Background Eraser Tool" see screen shot below:
Now open your image file and using your mouse trace out the background area. What I did was to move the tool
slowly around the outline of the smiley face without crossing into the red and clicking each small incremental
movement. This took me about 20 minutes. Then I used the tool to completely encircle the red face and
the hands. I then dragged the tool from this outline to the edges - so the background area was completely
covered with the checkered pattern. I got to the point where the result looks like the image below:
I thought this looked pretty good ( no inadvertent crossing into the foreground images) -
I saved the image as a GIF file which also changed the "Layer Tool" panel from "Background" to
"Layer 1". I guess by using the "Background Eraser Tool" somehow changed the layer name.
This is no problem since the tool did change the background. Ordinarily, the lasso tools cannot
modify the background when the layer is designated "Background" as described above. Okay now let's
view the image - see below:
Yikes - this looks pretty bad. If you look at the image with the checkered background ( above)
you can see some of the gray squares are not complete - you have to look closely. So I opened
the GIF image in Photoshop to fix the white specks - when I did the the layer name was called
"index" - and if I tried to use the background eraser tool I got a message to change the mode
to RGB. This is easily done by clicking on the "Image" tab on the menu bar and then "Mode" and
then click on "RGB Color" - so the layer name is back to "Layer 1". I then used the "zoom in"
feature ( select from the "View" tab on the top menu bar ) to clean up the broken and imcomplete
gray boxes. I only did this for the lower left hand corner of the image as this is way too
painstaking to do anymore. I used a high enough resolution to "see" which gray boxes were incomplete.
See new image below:
If you compare this image with the first one - you can see I did fix some white spots around
and below the hand on the left side of the image. There are still a few small dots. You get the
idea - this is very tedious work. So I think the best bet would be to use the lasso tools and
a graphing tablet pen to manipulate the lasso. The "Background Eraser Tool" seems a bit too
cumbersome for me. If you have better dexterity than I - then you may have more success.
Okay, there is one other avenue to explore. I used Corel Paint
Shop Pro ( my version is PSP Photo X2 ) to set the background transparency.
To do this, open up PSP and get the image. Now click on the "Image" tab
on the top menu bar - then "palette - then "Set Palette Transparency..". I
then got a message to change to 256 colors - which I did. Now
from the "Set Palette Transparency" dialog box click on the third
radio button ( ie, Set the transparency to palette entry ). Now put the
mouse in the white background area - it should turn into a dropper tool
and click the tool. The entry in the input box should change - in my case
the value was 250. See screen image below:
You can click on "proof" to see what happened. It should show the background
with a checkered patten fill - but the checkered patten also filled in any
white areas inside the face. The image is shown below - see how the background
filled in areas in the teeth and eyes.
Well this is almost what I want so now I opened Photoshop and and using this image I
used a brush tool ( with a white color ) and removed the checkered zones inside
the eyes and teeth. The revised image now looks like this:
The only problem with the image is that it has a thin white halo around the face and
hands. Although this method was easy to do - ie, change the transparency and some quick
editing with a brush tool, it still leaves a less than perfect result. If you display
a smaller image ( use the width and height attributes in the "img src=..." tag. see the
smaller image below ( not too bad and on a lighter background it would look better):