March 24, 2019

GIMP Tricks for Isolating Parts of Images

Erasing to Alpha

  • October 28, 2010
  • By Akkana Peck

You've been using GIMP for cleaning up your photos -- but now you have a picture of a kitten or a bird or your new smartphone that you want to paste into another picture.

It's one of the most common questions the GIMP community fields -- how do you take one part of a photo and make it ready to paste somewhere else? The answer is, "It depends." There are lots of different methods. Here are four of the most useful I've found.

<em>figure 1</em>
figure 1

Erasing to Alpha

For beginners, the easiest way to start is to erase everything that isn't the part you want. Click on the eraser tool (Figure 1) and start dragging in the image.

In Figure 1 I've chosen a round fuzzy brush, "Circle Fuzzy (10)". When you're cutting objects out of photos, you're almost always best off making the edges a little fuzzy. That way when you paste the result into another image, the edges won't be so obvious.

But wait. If you're starting from a JPEG photo, when you erase, all you'll get is white, where what you really want is transparent.

That's because JPEG doesn't allow for transparency -- it doesn't allow "alpha", the geek code-word for transparent parts of an image. Layer->Transparency->Add alpha channel will tell GIMP you want transparency.

Now when you erase, you'll see the grey checkerboard that means that part of the image is transparent. And there's one more trick: zoom way in. You can use the zoom menu at the bottom (Figure 2) or the View->Zoom menu, or the + and - keys. If you zoom way in, to 200 or 400%, you won't need the steady hands of an artist. Use short strokes, so that if you make a mistake you can use Edit->Undo.

<em>figure 2</em>
figure 2

When you're done, crop the image, either with the Crop tool or Image->Autocrop Image, and save it in some format that preserves transparency. That means no JPG. If you're not sure, use PNG.

Selection Tools

Erasing is easy and you don't need to know much about GIMP to do it. But eventually you'll probably want to use a more flexible method, a selection, where you select just the part you want. Then Edit->Copy remembers the selected part, and you can Edit->Paste it into another image.

There are lots of ways of making a selection in GIMP. For a shape like the penguin, you can use the Free Select tool -- its icon looks like a lasso -- to draw the outlines of the object you want to select. Enable the option to Feather edges, then click repeatedly as you "connect the dots" around the edge of the object. As with the eraser tool, zooming way in makes this a lot easier. When you get to the end, click on your starting point or hit Enter.

If you're selecting an object that's all one color -- say, a green leaf -- there are two tools that might help: Select by color and Fuzzy select. They're right next to each other in the Toolbox. To use either one, click on the tool's icon in the Toolbox, then click in the image on the color you want to select. The difference between them: Select by color selects everything anywhere in the image that's "close enough" to the color you clicked on, whereas Fuzzy select will only select regions connected to the place you clicked with the mouse.

How close does it have to be? The Threshold slider in Tool Options controls that ... but there's a faster way.

Most Popular LinuxPlanet Stories