“There’s more than one way to skin a cat.”
I’ll admit this is an odd proverb, but I think it is a great phrase to keep in mind when removing backgrounds from images in GIMP. That is to say, there are many ways to remove image backgrounds in GIMP, and there is truly no one right way to remove an image background in GIMP.
Why is this the case? Well, for starters, there are many tools found in GIMP that either produce a selection or remove backgrounds. And each one of these tools/methods have their strengths and weaknesses depending on your image.
For example, one tool may work best when the background is a solid color (i.e. a studio backdrop), while another tool or method works best when there is a lot of contrast between a foreground object and a background.
In this tutorial, I’ll go over a few examples of how to remove an image background for images with solid color backgrounds using GIMP 2.10.
Method 1: Fuzzy Select Tool (Quickest Method, Though Not Best Result)
In the image above, which is the main image we will be using for both methods in this tutorial and that you can download for free on Pixabay here, we have a model who is well lit in the foreground and has a solid black background behind her.
I’ll start by opening this photo into GIMP (right click on the photo in your file folder and go to “Open With” and choose “GNU Image Manipulation Program” if you are using Windows).
Next, right click on your main image layer in the layers panel and go to “Add Alpha Channel” (denoted by the green arrow in the image above). This will add a layer of transparency beneath your main image, allowing for the transparency to be revealed after we’ve erased the background (more on this in a bit). Without this step, your background color would show after you erase your background rather than transparency (which is not what you want).
There are 3 main tools I can use in this scenario to remove the background – all of which can be found in the Toolbox on the left-hand size of GIMP or by going to Tools>Selection Tools in GIMP’s main menu at the top.
The first tool is the “Fuzzy Select Tool” (denoted by the red arrow in the image above) – which allows you to “select a contiguous region on the basis of color.” In other words, you can click on a color in your image and, so long as the color is “contiguous” – or is basically uninterrupted by another object/color in the image, it will select all of that color. In our case, I will use the fuzzy select tool to select all of the black in the background.
With the fuzzy tool selected, I’ll simply click on the black background (as I have done in the image above). You should now see a selection area that goes around your model (you can always tell when there is a selection area because there will be moving black and white lines – called “marching ants” – moving around the selection area).
If the tool didn’t do a good job of selecting-out the model (or only selecting the black background), you can go to Select>None to deselect the selection area or hit ctrl+shift+a on your keyboard. Then, in the Tool Options for the Fuzzy Select Tool (just under the Toolbox), you can adjust the settings – mainly the “Threshold” setting (denoted by the red arrow in the image above) – to adjust the strictness with which the Fuzzy Select tool distinguishes the black pixels from other pixels. A higher Threshold number will mean the tool will be less strict (basically rendering it useless), and a lower Threshold number will make it more strict (meaning it won’t select any pixels that have ANY color deviating from black).
Now that you have your settings the way you want them, click on the background again to make sure your black background is indeed selected. Then, hit the Delete key on your keyboard. This should now delete everything that was inside the selection area, revealing a transparent background (which will show up as a checkerboard – as shown in the image above). Hit ctrl+shift+a on your keyboard to Select None.
You will probably notice that in your image there is still a faint trace of black going around the outer edge of your model. This is because the fuzzy select tool is not perfect – but you can fix this by continuing to adjust your Threshold value using the slider, or by checking the box labeled “feathered edges” and experimenting with the value (usually something in the range of 3-10 pixels works, though it depends on the size of your image).
This still may not fully fix the issue as the Fuzzy Select Tool simply is just not a great tool, in my opinion. However, it does get the job done very quickly, especially if you are just looking for a quick-and-dirty way to get rid of a solid color background. Let’s try another tool!
Method 2: Foreground Select Tool (Takes More Time, Produces Better Result)
The next method uses a tool called the “Foreground Select Tool” to distinguish a foreground object from a background object and create a selection area around the foreground object. Start by clicking on the Foreground Select Tool in your Toolbox (denoted by the red arrow in the image above). For those of you familiar with the other tools in GIMP, you’ll notice that your mouse pointer now looks like the same mouse pointer used for the Free Select Tool.
Next, draw a rough outline around your foreground object (denoted by the green arrow in the image above). It does not have to be very precise as the tool’s algorithm will detect where the actual line is between the foreground and background objects. Make sure you connect your outline’s endpoint to the original starting point to create a complete loop around your foreground object (it’s OK if your outline goes off the canvas and then comes back on, which is what I had to do in this case).
Once you have completed your outline, hit the enter key on your keyboard. This will highlight everything inside your outline in dark blue, and everything outside your outline in light blue (as you can see in the image above). Your mouse pointer will also now look like a paintbrush. Use the paintbrush to paint inside the foreground object – which tells the tool that everything you are painting is the foreground object. Try not to paint any of the background object as it may mess up your final result. When you release your mouse, the strokes you made will essentially erase any of the blue that was overlapping your subject (denoted by the red arrow in the image above).
As you can see, I loosely painted the foreground object, but stayed off of the black background. Hit the Enter key on your keyboard when you are finished.
After a few seconds, the light blue area that marks the background of your image should now more closely “hug” the line between the background and foreground object (as seen in the image above).
If there are any blue areas within your foreground object after performing this action, you can paint over them using your paintbrush (denoted by the red arrow in the image above), which will cause the algorithm to refine itself.
When you have sufficiently gotten rid of the blue items inside your foreground object, hit the enter key one last time. This should create a selection area around your foreground object.
You may still see some specs that were missed. To get rid of these, go to Select>Remove Holes (denoted by the red arrow in the image above). This should get rid of any small selection areas that were missed by the Foreground Select Tool.
Next, hit ctrl+i on your keyboard to invert the selection, or go to Select>Invert. Your background will now be selected. Hit the Delete key on your keyboard to delete the background. If a solid color shows up rather than the transparency checkerboard, make sure you have added an alpha channel to the main image layer by right clicking on the layer and going to Add Alpha Channel (this option will be grayed out if you already have it added to your image).
As you can see, this tool did a slightly better job of erasing the solid color background! If you still see imperfections, I recommend using the eraser tool to erase anything that was missed.
To save the image as a file type that allows for transparent backgrounds, go to File>Export As. Click on the “Select File Type by Extension” dropdown (denoted by the red arrow in the image above) and choose PNG as the file type. Click Export, then click Export again.