Computing: Computer Basics

Computing Home   Home   Contact

Home and Office: Making image backgrounds transparent with GIMP.

For most Windows users, editing photos and other images means the need to buy Adobe Photoshop, even though I think that there are (or at least were) functionnally limited versions of this application, that are free. Unix-based systems users know about the existence of an open-source software package for image editing: the GNU Image Manipulation Program (GIMP). Perhaps the most complete image editing software, that you may find, with even more functions and possibilities than Photoshop. And, there is a version of GIMP for Windows, too; it may be downloaded free of charge from the GIMP website. This short tutorial about making image backgrounds transparent describes how to do this, using GIMP; I suppose, that with Photoshop or other image editing applications, it may be done in a very similar way.

Why to make an image background transparent, you may perhaps ask. If you work with photos, you'll normally not need to do it, but imagine the following: You have one or several pictures (such as cartoons, for example), representing a picture and all around empty space, the image's background, white or of another color and you want to place them on your website or as part of a wordprocessing document, in a way to just see there the picture, but not the background. Of course, you can crop the image (cut out the picture; cf. my tutorial Cropping and resizing images), eliminating a more or less big part of the background and then filling the image backgound with the color of the global background of the webpage or the text document (normally white). This works well in most cases, however, consider the following:

The image considerd here is a PNG file with a colored picture on a white background; the background color could be another one, but has to be different from the picture colors. In fact, what we'll do, is changing all image regions with the backgound color to transparency. The general way to proceed in GIMP is similar to how you do with other applications: select something (in our case, a region of the image) and do some changements with the selection (in our case, change a color to transparency). Among the innumerous tools included with GIMP, there is one called "Select by color": It selects all regions of an image, that have a color identical to the one of the region, where you click with the mouse.

Open the image in GIMP (if it's a small image, you may use the "Zoom" function in the "View" menu to enlargen the display) and choose the Select by color tool (it's the first one in the second row of the tools icons).

GIMP: Choosing the 'Select by color' tool

Now click with your mouse somewhere on the image's background (i.e. outside the picture). All regions, having the background colors are now selected and you may apply any changements, you want, to them. If, for example, you'd like to color the blackground in pink, set the forground color to pink, select a brush and brush over the image. You do not need to worry to paint the picture: changements always apply only to the regions, that are actually selected.

In the menu bar, choose Layer > Transparency. Check the first two items of the opening submenu. If the first one is dimmed and the second one is enabled, the image includes an alpha channel (as is the case in my image) and that's what we need to proceed. If it's not the case, choose Add Alpha Channel. With the alpha channel present, choose Color to Alpha: This will convert a given color to transparency

GIMP: Converting a color to transparency [1]

The Color to Alpha dialog opens and you have to select the color, that you want to convert; in our case "white". Note, the other settings available: threshold and opacity affect how the conversion will exactly be done; have a look at the GIMP user manual, if you are interested in details.

GIMP: Converting a color to transparency [2]


As you have to select the color to convert in the "Color to Alpha" dialog box, opened from within the "Layer" menu, this seems to mean, that the conversion applies to all regions of the currently selected layer, and NOT to the selection done before! Anyway, selecting a region is never doing something wrong and by the way allowed to show, how to do to change a background's color...

All that remains to do, is saving the modified image. Choose File > Save to save your GIMP file (.xcf extension), then choose File > Export. Keep or change (to avoid overwriting) the original filename, be sure the export will be done to PNG, select saving options (keeping or removing the EXIF data, saving or not the file creation date...) and push the "Export" button. That's it!

GIMP: Exporting the modified file to PNG