[Courses][gimp] Lesson4: Basic selection tools, and copy/paste

Akkana Peck akkana at shallowsky.com
Sat Feb 19 08:56:41 EST 2005

In this lesson we'll explore some of GIMP's basic selection tools,
and some tricks for combining several images.  I'll conclude by
showing how to paste Tux, the Linux penguin, into photos.

I'll start with a photo of the Mitten Fault on the Green River
in Utah's Dinosaur National Monument:
(that's a scaled-down version for the web.)

It's a cool place.  But one thing you can't easily see in the
scaled-down version: down by the sandbar in the lower right quarter
of the picture are two kayakers coming down the river.  I'd like
to show a magnified version of those kayakers on the same image
that shows the whole scene.

I start by loading the full-sized image into gimp.  But I'll need
to work with both the full sized version and a scaled-down copy,
so the first step is Image->Duplicate to make a second copy.
(Of course, I could also use cp in the shell, then open that
file in gimp.)  Then I scale the copy much smaller, 550 pixels wide.

The next step is to go back to the original image and select the
kayakers.  I'll use the simplest selection tool for this: the
rectangular selection tool, the very first tool in the gimp toolbox.
(It's probably already selected by default when you start gimp.)

Go to the large image, and select as though you were using the
Crop tool: start at the upper left of the area you want, mouse down,
and drag down to the lower right.  Gimp will draw lines to show you
the box while you're dragging out the selection, and when you release
the mouse button, the selection is shown by a black-and-white dashed
line where the blacks and whites continuously change.  In gimp
parlance, this line is called the "marching ants".

Gimp's selection tools aren't as smart as crop, so you can't change
a selection's size easily once you've made it.  (You can move it;
I'll talk about that later.)  So if the selection you made isn't quite
right, click somewhere outside the marching-ants box (this will cancel
the selection) then try again, until you get the selection where you
want it.  (Be careful about clicking inside the selection: if you
click inside a selection then drag, gimp moves the contents of the
selection and leaves a white rectangle behind, which is almost never
what you want.  If this happens accidentally, Undo will fix it.)

When you have a selection, lots of things act a little differently in
gimp.  Most filters (for instance, the brightness tools discussed in
lesson 2) will only act on the selection, not the rest of the image;
and most drawing tools won't draw outside the selection.  We'll use
that for some useful effects later.

For now, though, what I want to do is copy the selection from the
big image, then paste it into the small image.  So I copy it:
Edit->Copy, or just ctrl-C.

Now I can go to the small image, and paste it: Edit->Paste, or ctrl-V.

What happened?  It pasted the selection as a new layer in the smaller
image, which you can see in the Layers dialog: it probably says New
Image, or Pasted Image.  But it's a Floating layer, which may not be
obvious from the name.  Gimp 1.2 will call it a Floating layer, but
gimp 2 just shows marching ants to show that it's different from a
normal layer (so it looks just like a selection).  Click the New Layer
button in the Layers dialog now to make it a normal layer.

The rectangle didn't paste at the place where I wanted it.
So the next step is to move it.  I can do that by selecting the move
tool: the same crossed arrow icon in the toolbox that we used to move
the text layer around in lesson 3.  Using the move tool, I'll drag my
box down to the green area in the lower right of the image.

What if I want to see what the image looks like without that
dotted-line layer boundary?  Selecting the other layer (probably
called "Background") in the layers dialog will draw the outline
around that layer (the whole image) instead of the smaller layer.

Now I have my little box showing kayakers pasted on top of my
scaled-down image.  But it looks weird -- it's hard to tell that
that rectangle is something I put there intentionally.  So how
can I fix that?  Easy: add a drop shadow!
(Script-fu->Shadow->Drop-Shadow... just like in lesson 3.)
I could even use a different color for my drop shadow to make it stand
out more, though in this case I couldn't find one that didn't look
garish.  If I save the image now as jpg (of course I have to let gimp
export it since I now have multiple layers), it looks like this:

But rectangular isn't the only type of selection gimp has.  Right next
to the rectangular selection tool is ellipse select.  It works the
same way as rectangular select, only it lets you make ovals and
circles instead of rectangles and squares.

If I follow exactly the same procedure as before, but I use ellipse
select instead of rectangular, and play with the drop shadow color,
I get the rather strange looking:

To close the lesson, I'll talk about one more selection tool:
well, actually two closely related ones, Select Contiguous Regions
and Select By Color.  And who better to introduce these useful tools
than everybody's favorite penguin?

(Incidentally, Tux was created by Larry Ewing, drawn freehand in
gimp version 0.54.  It's legal to use him or make changes as
long as you credit Larry Ewing and the GIMP if anyone asks.
The artist has a page describing how he was drawn:
http://www.isc.tamu.edu/~lewing/linux/notes.html )

Now, Tux is cute all by himself, but what if I want to take him
along on my trip to see the Mitten fault?

First I decide how big he'll need to be.  100 pixels high looks about
right; so I scale Tux to that size.

Next, I need to select Tux (but not the background around him),
so I can paste him into the photo.

To do that, I need to select Tux himself, and not that white
background behind him.  (Or I could go download a tux image that
already has a transparent background from Larry Ewing's page --
but then we wouldn't have this part of the lesson! :-)

To do this, I choose the toolbox icon that looks like a magic wand
with a light on the end, with the tooltip "Select Contiguous Regions".

This tool will select everything that's of similar color to the place
where I click.  How close it needs to be is defined by the Threshold
in the tool options: if you set Threshold to 0, then only identical
colors will be selected.  For this particular example, make sure
Feather Edges is turned off.  What I'll do is select the background,
because it's all one color, whereas Tux isn't.

A very similar tool is Select by Color.  In gimp 2 it's in the
toolbox right next to Contiguous Regions; in 1.2 it's in the menus,
Select->By Color.  If you click on a white pixel, then EVERY white
pixel in the image becomes selected.  Try it on Tux!  You won't want
it for this exercise, but it's a very useful tool for some images.

With the Contiguous Regions tool chosen, I click anywhere in the white
background.  Voila!  I see marching ants around the edge of Tux, and
also around the outside edge of the image.  The background is now selected.

But I don't actually want the background, I want Tux himself.  I want
the selection to be the exact opposite of what it is.  That's easy to
fix: Select->Invert.  Now Tux is selected: I still see the marching
ants around him, but no longer see them around the edge of the image.

Now I'm ready to Copy, then Paste into the photo.  Click on New Layer,
select the move tool, drag the Tux layer to where I want him ...
and voila, Tux Visits the Mitten Fault!

Select something from one image (using any selection tool) and paste
it into another image.

Next lesson: basic drawing tools.

More information about the Courses mailing list