How to Change a White Background to Transparent with Photoshop
Undoing the evil deed of flattening a vector graphic, one JPG at a time.
This tutorial will teach you an effective method for isolating graphics such as logos and icons from white backgrounds. We essentially use the graphic to mask itself off from the background. It is always preferable to get the original graphics if possible, but for those situations where a flat image is all you have, this technique may just save the day.
Here is a quick preview of what you can expect from using this technique, the image on the left is a flattened JPG file with no transparency layers. The right side is the same image after using the technique in this tutorial.
The first step is to open your image in Photoshop. I am using a logo from this set on Medialoot.
Now of course, the actual logo template is completely vector, but in this hypothetical situation we are going to pretend that some deranged lunatic has flattened the logo into a JPG and deleted the original file from existence (the horror!).
Double click on the background layer to unlock it, and then create a new Hue/Saturation Adjustment Layer.
Open the Properties window and turn the Saturation all the way down to -100 on the Hue/Saturation adjustment layer.
Add a new Invert adjustment layer.
Add a new Levels adjustment layer, and in the Properties window adjust the highlights input value until the areas that you want to be 100% opacity are #FFFFFF (you can use the eye dropper tool to check what color individual pixels are).
The background should already be #000000 if it was pure white to begin with.If it isn't then you will also need to adjust the shadows input level.
Press CMD/CTRL+A to select all, and the CMD/CTRL+SHIFT+C to Copy Merged.
Click the layer visibility icon on all 3 adjustment layers and select the original layer again. Press the Add layer mask button at the bottom go the Layers window.
Open the Channels window (Window > Channels) and click the layer visibility icon on the newly created Mask channel. Then press CMD/CTRL+V to paste the image into the mask.
Click the layer visibility icon on the Mask channel again to turn off the red overlay and see the results.
This is actually looking pretty good now, especially on transparent and lighter colored backgrounds. But something unexpected happens on darker backgrounds. The edges become very rough looking and unpleasant looking.
Luckily there is a simple fix.
Press CMD/CTRL+G to group the masked layer and then with the group select ALT+LEFT CLICK on the mask layer icon to create a selection.
Go to Select > Modify > Contract... and enter the 1 pixels then click OK.
On high resolution images you may need to increase this to 2 pixels or more but it's best to try the smallest possible value first to avoid unnecessary masking.
Click the Add new mask button again to create a new mask on the group layer. The result are much better this time around on both light and dark backgrounds.
With that being said, it unlikely we would ever want to use such a dark text color on a dark background anyway. But I wanted to share the additional steps for smoothing out the edges just in case.
Here I selected the gray elements of the design with the marquee tool and Inverted them with an adjustment, and also used a Levels adjustment layer to make the gray elements white instead.
And here is the result. We have gone from a completely flattened JPG image to a versatile transparent logo that works on both light and dark backgrounds. Just be sure not to save it as a JPG again.