Whether you’re working on graphics for a design project or a photorealistic art piece, you’ll often need to erase certain parts of the layers and images you’re working with. Erasing backgrounds allows you to isolate your imagery, but there’s a trick to using the technique in GIMP.
If you try to erase the background of an image in GIMP using the Eraser tool, you’ll just wind up painting with your selected background color – unless you add a new image component known as an alpha channel that can keep track of the transparency levels in your image.
Most digital images are made up of three color channels: a Red channel, a Green channel, and a Blue channel, which are combined into a standard RGB image as you see everywhere across the web.
Adding an Alpha channel allows GIMP to track which areas of your image are transparent and which are opaque. GIMP also allows you to delete the background to transparent.
Here’s how you can add an alpha channel and start erasing transparency in GIMP:
Step 1: Open the Layer menu, select the Transparency submenu, and then click Add Alpha Channel.
If you check the Channels panel, which is located in a tab next to the Layers panel in the bottom right corner of the GIMP interface, you’ll see there is a new entry in the list below the standard Red, Green, and Blue channels.
Step 2: Switch to the Eraser tool using the toolbox or by pressing the keyboard shortcut Shift + E. Click and drag to start erasing, and you’ll automatically be erasing to transparency!
That’s all there is to it!
If you find that you’re working on an image that already has an alpha channel, you won’t need to bother with adding another one, and you can just skip right to Step 2 and start erasing to transparency right away.
There are also a couple of other situations where GIMP might automatically add an alpha channel for you. Whenever you create a new layer that has been filled with transparency, GIMP will automatically add an alpha channel to your image in order to handle the new transparent layer.
There are also some filters that can cause GIMP to add an alpha channel, such as the Color to Alpha filter, which automatically turns all the pixels of a specific color into transparent pixels.
Additionally, some image types like the PNG format, which is most commonly used for transparent images, may automatically include an alpha channel although JPEGs and other common file types may need to have one explicitly added.
Other Methods for Erasing to Transparency
You don’t have to use the Eraser tool in order to get a transparent background in GIMP. In my example image of my Cephalotus follicularis, also known as the Australian Pitcher Plant, it would take a very long time to get a perfect outline around the entire plant using the Eraser tool to do it all by hand.
Because it’s on a nice bright white background, it is much simpler to use the Fuzzy Select tool in order to select the entire background with a single click. Then simply clicking the Delete key is enough to erase all the pixels within my selection so that they are all transparent.
Once you’ve removed certain parts of your image, you’ll find that the Alpha channel’s thumbnail has been updated to show which pixels are opaque and which are transparent, as you can see in the screenshot above.
Exporting Your Transparent Image
In order to keep your transparent pixels when you export your image, you’ll need to export using a file format that is capable of preserving the alpha channel. The most widespread image format for transparent images is the PNG or Portable Network Graphic format, and GIMP can export to it easily.
Open the File menu, and choose Export As.
In the Export Image dialog box that appears, click the Select File Type (By Extension) option at the bottom of the window. A list appears showing you all the formats GIMP can save to, which is quite a few! Scroll to find PNG in the list, and click Export.
You can also simply add the file extension .PNG onto the end of your filename, and GIMP will understand that you want to save it in the PNG format.
GIMP will then give you a few options about how to save your PNG file, although the default options should be fine unless you’ve edited them. If you’re not sure what settings to use, you can always click the Load Defaults button to reset everything.
If you try to export an image with transparent pixels into the JPEG format or another format that doesn’t support an alpha channel, they’ll just appear as pure white or pure black in the final image, depending on where you view it, so be sure to stick to PNG for this task.
That’s just about everything you’ll need to know about how to erase to transparency in GIMP! It’s a useful skill for all kinds of editing projects, so be sure to practice until it’s second nature =)
About Thomas Boldt
David Coulthard
when using the eraser to get a transparent background frustratingly doesn’t work could you take the reader through work arounds.
thanks
David Coulthard
ok a bit to quick to post – found my own solution – when importing a pic remove the alpha channel then add an alpha channel and then it works – don’t know why but it works.
thanks
Thomas Boldt
Hi David, that’s a strange result, but I’m glad you figured out a solution – and thanks very much for coming back to share it with me and future readers!
What kind of file were you originally working on that had an alpha channel which GIMP didn’t recognize properly? That might provide a bit of a clue as to what went wrong.
Cheers!