Saturday, March 16, 2013

GIMP Basics -Introduction + Beginner tutorial exercise

Gimp Getting Started

Chapter 1. Getting Started

Introduction


The GIMP is the "GNU Image Manipulation Program." The name is more descriptive than most because it tells you that the program is released under the GNU Public License (meaning it's free to use and free to modify), and that it's a program for modifying or creating images.


This tutorial is highly informal, and is a walk-through of some fairly basic things that can be done with the GIMP. I hope this task-oriented tutorial will be more helpful to people than a more formal structurally oriented introduction.


Where to Get the GIMP

The GIMP homepage is at http://www.gimp.org/ where you should follow the "Download" link. This will get you the latest version.


Chapter 2. Adding Text to an Existing Image

Loading an Image in the GIMP

Start the GIMP. If this is your first time running the GIMP, you'll be walked through setting up the configuration files - accepting the defaults works well.

The GIMP usually starts several windows when it runs. Look for the one pictured below, which is the main panel.






The GIMP main menu.
Press "File" and select "Open."
Open an existing image file you want to work with, the GIMP understands almost all image file formats in existence today. We'll be making several modifications to this image - please save it under a different filename, don't overwrite your original! The modifications I'm going to work through may not improve your image, but you can try these changes to see how they work.

 



An image window in the GIMP open on a scanned slide.



Resizing the Image

Note in the title bar that it has a "33.3%" indicator. This indicates that the image is much larger than it appears. This tells me that the image is bigger than I want it to be, so I'll scale the image down. Click on Image menu> Image Scale..." I've chosen to reduce the image to 50% of its original size:  Click image size drop down change to percent. Change width to 50% and the height will adjust accordingly. Click Scale.






The Image Scale window.
Notice that by default the ratios are locked (or "chained") together: when I change one, the other follows. This is usually what you want so the proportions of the image remain the same. The resized image appears smaller, as you might expect. To work with it at 1:1 (100%), Click View> Zoom> 1:1". You'll notice that there's a number "1" after "1:1" on the menu - this indicates that you can do the same thing by pressing the 1 key.

Now we have another problem: we can't see the whole image. The window we're working in stayed the same size while the image inside it doubled in size, so now we have scroll bars along each side of the image. Scroll bars are a good way to move around a large image (or one you have at high magnification to see the details), but in this case it would be nice to see the whole image in one window without scrolling.


  



Part of the image showing in a window, with scrollbars.
Select View> Shrink Wrap and you'll have the whole image available to you (if it will fit on your screen).

Adding Text

We'll now add text to this image. To select the text tool, go to the ToolBox panel, and click on the "A". This selects the tool. In this case, we'd like to change the tool default values: that's done by double-clicking on the tool selector. Double click on the "A" and you should see a window like this:






The Text Tool Options window.
If you move the pointer over the image, you'll see that you get the "I-beam" indicator, showing you that if you click on the image you'll be inserting text. Each tool you can use in the GIMP has its own cursor indicator like this, and you'd be wise to pay attention to what the cursor is telling you. If you click on the image with the wrong tool, you can do some bad things to your image.

Which brings us to another digression about a very useful key combination. "Ctrl-Z" is possibly the most important thing you can learn about the GIMP. It means "Undo the last change." Please note that you have to have an image window selected for it to work. You can undo multiple changes - usually five, although you can reset the value in the defaults.

Click on the image to bring up the text box.


And enter your text.




The picture with text added. Note the black and yellow dashed line around the text. This indicates that the text has been created in a new layer, and that means it's time for another digression.


Layers

The commonest comparison for Layers is a stack of transparencies. The background (in this case, the initial image we chose to edit) cannot have an alpha channel (be transparent), but you can add layers on top of it that are. In the case of the text layer you just created, it's transparent everywhere there isn't black text. You should also notice that the text layer is much smaller than the image: layers don't have to be the same size. If we added another opaque layer on top of our image, then you'd only see the opaque layer on top. Layers can also be partially transparent - we'll get to that.

To see what layers we have, let's open the Layers, dialogue box.
You should see something similar to the following: If your layers tab is not present on the right is a small arrow click on it and select add tabs to add tabs to your toolbox.



The Layers Dialogue box.

Note that we have three layers, one titled the name of the file (which is the original image), one titled blank layer and the third the text which was added by the text tool. To rename a layer double click on the layer name, change the name and press enter. There are a lot of things you can do with layers. The most basic is controlling the visibility of the layer: click on the eye icon beside the layer to toggle its visibility on and off. You'll find that if you turn off the Background, you'll see a checked pattern of light and dark gray squares. This indicates that there's nothing visible in any area where you see that pattern. Leave both layers visible when you're done.

If you click just to the right of the eye icon, you'll see the link icon (blank box) click on it and it becomes a chain. Clicking on them toggles them on and off. Leave these turned off for now.

Notice that if you click on a layer (towards the right side, away from the eye and link icons) the layer becomes highlighted. When the layer is highlighted, any tools you use will be applied to that layer - even if the layer isn't currently visible because it's behind another layer or the visibility is toggled off. I've been caught off guard by that, it's something to watch out for. Always be aware of which layer is selected so you know what you're working on.

You can create new layers (the single piece of paper icon in the Layers dialogue), or duplicate existing layers (the double pictures in the dialogue). New layers are usually used to overlay another visual piece on an existing image, while duplicate layers allow you to change existing data while simultaneously keeping it in unmodified form.

Try right-clicking on a layer and notice that there's a menu associated with the layer. This is material you'll have to explore on your own.

Placing and Modifying the Text

With both the layers visible and the text layer selected, choose the move tool (the crossed arrows) in the main panel. Now move the cursor over the text we added to the image, noticing that the cursor changes between a hand when you're over the background and a move icon when you're over the text. In fact, if you click and drag on the background rather than the text, you'll move the background. Remember that you can undo mistakes with Ctrl-Z. Move the text to where you think it looks best.

With the text layer still selected, right-click on the image and choose Layers> Layer to Imagesize." This will increase the size of the text layer to match that of the image. The utility of this change isn't particularly obvious at this point, but it's helpful in some of the changes we'll be making later, it doesn't cause any problems, and I find the layer border (the yellow and black checked line mentioned earlier) distracting. This is one of several ways to resize a layer.

Now duplicate the layer. to do this, make sure the text layer is selected in the Layers window, then press the doubled piece of paper.




Duplicating a layer in the Layer dialogue box.

So you have two copies of the text. It doesn't look any different ... Since they're in exactly the same place, they overlay each other and the original copy can't be seen because of the new copy.
Let's keep better track of our layers - we can name them, and this will become very useful when you start working with multiple layers. Go to the Layers, Channels & Paths dialogue box, and double-click on the new copy. Replace Working Man copy with something like Text 2.

We're now going to blur the Working Man layer, so make sure it's selected in the Layers dialogue box. I would also recommend that you make the top layer Text2 invisible by clicking on the eye icon, but this isn't strictly necessary. Now right-click on the image, select Filters>Blur>Gaussian Blur. There's not a lot of practical difference between RLE and IIR. RLE is slightly better to use on computer generated images. You'll now be presented with a dialogue box like the following:




The RLE Gaussian Blur dialogue box.
Set the Blur Radius to 5 and press OK. This should result in the text you've been looking at being replaced by a very blurry version of itself. This is going to be our drop shadow. But being a drop shadow, you don't want it directly behind the original, but offset down and to one side. There are two ways to do this: either click and drag it, or use the Offset menu item. The problem with click and drag in this case is that you can't see the Text layer, but if you turn its visibility back on, then it's hard to click on the shadow to drag it because it's hiding behind the top layer...So I use Layer>Transforms> Offset  This brings up another dialogue box:





The offset dialogue box.
To move the shadow down and right enter 3 and 3. After saying OK to this, turn the visibility of the top layer of text back on. I felt that the appearance of the shadow was too heavy, so I went back to the Layers window where to move the Opacity slider for the Text Shadow layer down to 50. This leaves the shadow still visible, but not obvious. When you have a very heavy drop shadow, it's more obvious how the 3-D effect is created and it can lose some of its magic because of that. Subtlety is a good thing ...

Adding a Background to the Text

We'll now add a background to the text to emphasize it a bit more. Add a new layer (if in doubt, add a new layer - you can merge layers easily, but separating them is difficult to impossible) in the Layers dialogue by clicking on the single sheet of paper. You'll get a new dialogue box for New Layer Options. The defaults should be good, but make sure that Layer Fill Type is set to "Transparent." With your new layer selected, use the arrow keys in the Layers dialogue to move the new layer down the layer stack until it's under the two text layers.




Moving layers - press the down arrow twice to move the selected layer down the stack to its new position.
In the main GIMP Toolbox panel, select the Rectangular Select tool (the dashed square). Put the pointer over the image and select a box slightly larger and centered around the text:




Here you can see the drop shadow, a second blurred and half transparent copy of the text. You can also see the "marching ants" selection box centered around the text.

To blur the edges of the selection, use the Select>Feather dialogue, using a 10 pixel feather. Select the bucket fill tool from the main panel (it's easy to spot - it's a bucket). By default, bucket fill uses the foreground color - that's the color in the lower left corner of the main panel. The upper, dominant color (usually black by default) is the "foreground" color. Reverse the foreground and background colors by pressing the double-ended arrow by the colors:




Reversing the foreground and background colors.

Click inside the selected area in the image. This should bucket fill the selected area in your new layer with white. Again, subtlety is good: reduce the Opacity of the layer to about 30 (what looks good will depend on the color of the image you're working above). To get a good look at your new creation, use Select>None to get rid of the marching ants. Depending on your image if the white is too much of a contrast with the image you can select the blur tool from the tool box and blur the edges or instead of white select a color that matches your image better.

Saving the Image

The GIMP can open almost any kind of image format available today, and it can also save in almost any format. But unless you're absolutely sure you'll never want to edit the picture again, save in the GIMP's native format, XCF. XCF files save all the layers, channels, and paths you've created. It even stores undo information, and it's not a lossy format. As a result, XCF files tend to be very large.

Use the File>Save As...dialogue to save the image.

XCF files can't be viewed by web browsers, so do File>Export... Click the Select File_Type (By Extension) to open the drop down menu.



The Export file dialogue box.

As this states, the PNG file format can't deal with layers, so the GIMP pushes all the layers into one before saving as a PNG. If your background has transparent areas (not the case here) the GIMP will fill it in with some color. Since we have transparency but it's not in the Background, the result will be a PNG that looks almost exactly like what we see in the GIMP. Click on Export. But you're not done yet: most file formats have their own set of options, and PNG is no exception:




The Save as PNG dialogue box.

Here you can adjust the Quality or compression - and several other things. The higher the compression, the smaller the image - and the poorer the final image quality. 




Chapter 3. Creating a New Image

Starting from Scratch

To create a new image, use the main menu File>New. This will create a new blank image 256 pixels square with a white background - if you haven't changed the defaults. But let's make something a bit bigger: change the settings to 512x512 pixels. See the dialogue box below. Click on Advanced Options to select a transparent background.





The New Image dialogue box.
The steps we're going to move through now aren't going to create an image worth keeping: this is to demonstrate some of what the drawing tools in the GIMP can do. I'd recommend following the steps I lay out as we move along: a little dull, but there's a reason for the structure.


The Drawing Tools


 

The drawing tools available in the main panel. Look for the specific icons I've marked, not the location - your GIMP panel may be layed out differently than mine.
The available drawing tools are pencil, brush, ink, and airbrush. There's also an eraser, the gradient tool (not indicated on the above picture), and "bucket fill" which we saw previously. Each has special properties.

Let's start with the Ink tool. Choose a color: do this by clicking on the foreground color to get the "Color Selection" dialogue.

Color Selection



The Color Selection Dialogue box - I'm choosing a slightly off red.
Notice the set of tabs along the top of the Color Selection dialogue box: each brings you to another way to select colors. I generally use the default GIMP method, but I sometimes use the Triangle as well. Maybe one of the others will suit you better. Notice that GIMP and GTK both allow you to control RGB (Red-Green-Blue) and HSV (Hue-Saturation-Value), and that the GIMP method uses hex values whereas the GTK one uses a range of 0.0 to 1.0 ... Probably not deeply important to you now, but you may want these methods of creating colors later. Right now, choose a color, select the ink tool, and draw a horizontal line - as you draw, move slowly then quickly to see what I mean about speed sensitivity.

Now select the pencil tool. It draws plain lines with sharp edges (even if you've selected a fuzzy-edged brush - we'll get to them shortly). Pick another color and draw another horizontal line below the previous one. Notice that the width doesn't vary if you speed up or slow down.

Brush Selection

Select the paint brush tool now, and select another color. But this time select a new brush. Click on the brush channel tab (if you do not have it showing now is a good time to add it to your channel tabs). So far we've been using the default brush, which is a hard edged circle 19 pixels in diameter. As you'll see, you have a lot of choices in brushes. Notice that there's even a New button...on the drop out menu...you can create your own brushes if you want to.




The brush selection dialogue box.
Select a different brush
Draw another horizontal line beneath the other two.
Let's try one more pedestrian lesson before we move on to the really interesting stuff: select the air brush tool, and pick the sharp edged 19 pixel brush again. Pick another color. Draw another horizontal line below the previous three. Draw VERY slowly in places, and notice that the longer you stay in one place, the more paint it leaves behind.


The first set of lines drawn with the various paint tools.
Let's try out the eraser. Select the eraser tool from the main panel, and run in vertically down across the other lines you drew. Notice that it erases in the shape of the brush that you have selected. An important note is that on any other layer than the background you would remove ALL color - the area you erased would become transparent. On the background, it erases to the original background color.

Select the paint brush tool. Double-click on the paint brush to bring up the Tool Options dialogue window. Notice that we have a huge selection of options. Set the opacity to approximately 50.0 and draw another vertical line cutting across your horizontal lines. Notice that the resulting line isn't entirely opaque, as you might expect. Draw another line half overlapping the one you just drew, and you'll see that the effect is cumulative - where the lines overlap, the yellow is stronger.

Adjust the paintbrush tool options again - reset the opacity to 100% and set the Mode to Difference. Draw another vertical line crossing your horizontal lines. The first surprise is the color: you'll find that at first it seems you're drawing in blue, until you hit another line. Since the mode is set to difference, the color you use is inverted when you draw on a white background, and you get the difference of colors every time you cross another line. Since blue and yellow are color opposites, when your yellow line crosses the blue line, you get white - because blue and yellow are completely different. At this point, we've moved into a realm of drawing that has no parallel in the physical world of paper and paint - up until now, you could almost imagine yourself doing all of this on paper ...


Air brush and painting with difference mode added.
There are a lot of different modes, and you know how to change them now. Whether they're of practical use to you will depend on how you choose to use the GIMP. I recommend that you experiment at least a little with the modes to see what they do - but that exploration is up to you.

To close this section, let's take a quick look at a couple more painting tricks. First, set the paint tool options mode back to Normal. Then click on the brush in the main panel and change to the Confetti brush - it looks about the way the name implies, a bunch of confetti. Change the color to red and draw another vertical line with your new brush. You'll notice as you draw that this brush only marks your canvas very infrequently. Part of brush design is deciding how often the brush will print itself on the canvas - most brushes do it so frequently that the result looks like a solid stroke, as you would expect from a real life brush. As unusual as it is, behavior like the Confetti brush can produce very interesting results.

Chapter 4. Tiles

Other Tutorials

At this point I'm going to point you to some other tutorials for the GIMP rather than duplicating good work that someone else has already done: http://www.gimp.org/tutorials.html. Follow through The Basics and Easy Patterns at least. You'll find some duplication of what I've discussed, and some of the new material that you cover I'll cover again later, but I hope that most of it will be complimentary.


Starting a Tile

Since I'm most familiar with making tiles, that's the subject we're going to discuss in this chapter. When I say tile, I mean an image that matches up with itself along the edges so you can use it as a seamless repeating background. I like to make tiles for use as computer screen backgrounds - that means rather less visual subtlety than you might use for a web page background, but most of the same principles apply.

I generally use the GIMP's extensive selection of filters to generate images. That's what I'll be covering in this chapter, as using drawing tools was covered in the GIMP tutorial mentioned above, Easy Patterns.
Start a new image. I'll be working at 512x512 pixels in size, but the choice is yours. As always, remember that the bigger the image is, the more space it takes up.

Now might be a good time to mention the wonders of tear-off menus. There are certain menus that I end up using a great deal, and it becomes tedious to keep right-clicking on the image and then navigating the menu system to the item I want only to have to repeat the process almost immediately. The authors of the GIMP have come up with a fairly nice solution to this: right-click on the image, navigate to the menu you want to use I would suggest Filters and notice at the very top of the menu there's a dashed line. If you put your pointer over that, you'll notice that it becomes highlighted like any other menu item. Click on it, and the menu becomes its own window that you can position anywhere you want.




The Filter menu, after it's torn off.

I recommend creating most new material for tiles on their own layers - particularly when you're working with the Render menu item, as it overwrites the current layer. So as a first step, create a new layer. Now click on Render in the Filters menu, and select Clouds> Solid Noise... In the dialogue box that appears, click the Tilable check box. This is obviously a really nice feature to have if you're working on tiles, and it's available in a few of the dialogue boxes we'll be working with. I'm going to click the Turbulent check box as well because I like the effect. If you're curious, you can create a second layer with Turbulent toggled the other way so you can see what the two do differently. The Random Seed setting is interesting too: by default it's set to 1, and if you come back to this dialogue later, you'll get the same pattern again with the number set on the same time. If you want to get a different pattern each time, click the Time button and you'll get a (mostly) random number chosen every time you generate a Noise picture.




The Solid Noise dialogue box.
To verify that the material you've created is tilable  right-click on the image, select the layer>Transforms> Offset ... In the dialogue box that appears, select the Offset by (x/2), (y/2) button. You'll notice that it puts 256 in the X box and 256 in the Y box. Click offset The image is offset by 50% in both directions, and you should still see a seamless image. If you don't, go back and check that you had the Tilable button switched on. Remember to perform this check occasionally. You can now click CTRL-Z to reset the image to its original position. In fact, I'd recommend this - not because it's necessary now, but if you make tiles much you'll find yourself working with layers that match up in a particular position, and offsetting one will ruin the image. So hitting CTRL-Z to undo the change is good practice.

Make a new layer. In the new layer, use Filters>Render>Clouds> Plasma...Ok to generate some colors to add to this black and white image. Now hit CTRL-SHIFT-O (the keyboard equivalent of the Offset command we just used) and offset by x/2, y/2. You'll immediately see that Plasma doesn't render a tilable image. Use CTRL-Z to set the image back where it was, and now select Filters>Map>Make Seamless. I'm not too crazy about this filter, but it does work. You may notice bands of color half way along each edge of the image, and that's the price you pay for Make Seamless. Finally, go to your Layers Channels dialogue box and set the mode of the plasma layer to Overlay. You now have a tilable image that you can save. Try setting the plasma layer's mode to other modes, and see how they look too.



The final form of the tiled image.
The tile we've generated isn't that exciting, but in combination with the previously mentioned GIMP tutorials you should be on your way to creating something much better.

If you're interested in making tiles, I would highly recommend that you download the Plasma2 plugin from the GIMP plugin registry at http://registry.gimp.org/.


Chapter 5. Miscellaneous GIMP Features

Introduction

As I've emphasized many times, the GIMP can do many things. I'm not going to go into as much detail as I'd like about the various features mentioned in this chapter, but I wanted to point out they exist. They're the ones I use the most, and I'm stretching that to guess that maybe they'll be useful to you. This section is incomplete - I hope to finish it up later.


Taking a Screenshot

Many programs can take screenshots, but few are as good at doctoring the image after it's taken as the GIMP is.

On the main panel, click on the File menu, and select Create> Screen Shot ... I've used this feature extensively while creating this tutorial.



The Screen Shot dialogue box.
Setting the delay to three seconds: After three seconds the GIMP takes a screen shot of whatever window you clicked on - if it isn't at the front, the GIMP takes the shot with whatever other windows are overlaying it. That's why I chose the three second delay, so I can click and bring the target window to focus before I click to take the screenshot.


Adjusting Colors

If you have a bad image (poor quality scan, bad exposure ...) it can sometimes be rescued by adjusting the colors. The GIMP provides a multitude of ways to adjust colors. Click on the Colors menu where you'll find another menu populated with several different options. My preference is for the Curve... dialogue: you can do pretty much anything with it that you can do with any of the other options, and I find I understand it more intuitively. Please note that you may try it out and decide it's totally UNintuitive: you need to see which method works for you.
Let's start with the seamless plasma from the tile chapter (I've set the layer mode back to "Normal"):




The seamless plasma image.
Open the Curves... dialogue. The default for Curves is to modify the brightness of the entire image - but you can choose to work just on a specific color channel. Here's the results of the most basic "drags" you can do on the curve:




Dragging the curve down darkens the image.



Dragging the curve up lightens the image.

  


Creating an "S" curve increases contrast, but creating an inverted "S" curve like this one reduces contrast.



Chapter 6. Other Resources

The tutorials at the GIMP site are very good: tutorials
There are at least two books available online: the GIMP User's Manual, aka GIMP: The Official Handbook available at manuals, and Grokking the GIMP available at Grokking. Of the two, I definitely favour the latter: it's fairly straight-forward, while I find the former difficult to use online and sometimes overly complex. Both are also available in paper versions: I think I'd like the User Manual better in paper, but I don't own it and can't say for sure.

Two other good books on the subject are Alex Harford's GIMP: Essential Reference, published in 2000 by New Riders, and Michael Hammel's Essential GIMP for Web Professionals published in 2001 by Prentice Hall PTR. Of all of these books, I find myself referring to GIMP: Essential Reference the most. I'm not sure it's the best to learn from (Essential GIMP for Web Professionals was pretty good for that), but once you know the GIMP it's very well organized as a reference (I don't take it for granted these days that something that says it's a "Reference" will actually be good for that ...)
The GIMP plugin registry at Registry

GIMP The Basics

GIMP Basics


This is a video walk through of the installation and user interface of GIMP, made by a university instructional design staff member, so you can expect a very easy-to-follow and informative narrative. In the video, he goes over how to perform 7 basic image editing tasks: scaling, cropping, cutting (with transparency), flipping, rotating, reducing and saving.

By watching these, you’re basically going over the first text tutorial on GIMP.org, GIMP Lite Quickies.






Optimizing Images For Web Use


The following video shows how to export a file to JPEG and monitor the file size of the new image. There’s a small hiccup from 1:10-1:30 in the video, but it’s definitely helpful to know that you can select and preview the quality of the new image before you save it especially now that lots of sites have restrictions on maximum file size.

In the video, the user tries to save a JPEG with the highest quality while keeping her image under 256KB which is the YouTube limit for channel background images.




Feathering


This technique creates a fuzzy frame (this “frame” has an adjustable radius, of course) around a spot in the picture you may want to focus on or copy and paste somewhere else, in which case, the pasted image will blend “unobtrusively with its surroundings.”




Paths


The Paths (aka, Bezier curves) tool can help you create more defined shapes by making anchor points. The following GIMP tutorial shows how to cut a piece from image 1 to paste as a layer into another image, using the Paths tool to complete the outline around the piece. Using this tool will allow more control over the outlines or shapes.




Brushes


According to the user manual, brushes are pixmaps from the paint tools (except for the ink tool) used for painting, erasing, copying, smudging, lightening or darkening, etc. GIMP has a set of basic brushes, but if you don’t find what you are looking for, check out the following video to see where and how to find and install brushes.




QuickMask Mode


QuickMask mode is basically a more intuitive way to fully visualize your selection, so you can do more precise work and effectively adjust your selection when the marching ants just aren’t enough, as according to the official GIMP user manual, “what the marching ants show you as either inside or outside the boundary is really just a slice through a continuum.” For more information, watch the video below.




Filters


Red Eye Removal: If you’re ready to play around and get familiar with the simplest of the filters, try following this really simple GIMP tutorial, which you’ll be able to complete very quickly. This is useful if your camera doesn’t have settings to optimize lighting (and thus, prevent red eye) or you have older pictures lying around that could use some red eye removal.





Drop Shadows


To create more depth to text and objects, consider adding a drop shadow by selecting an image (in a specific layer) and going to Filter > Light and Shadow > Drop Shadow.





Layers


Layers are individual transparencies on top of an image that can add easily removable effects to specific parts. The following video will also go over layer modes, transparencies, and layer visibility.




This should get you pumped up enough to dabble in GIMP. After this, you should be able to follow those more advanced tutorials, whether they’re text or in video.