Introduction to Layers

Done using GIMP 2.8 on Kubuntu Linux 18.04 LTS

If you ever had a chance to see how classical animation like the old Disney films was done you might have learned that they used what are called “animation cels“, where cel is short for celluloid. The idea was that a background would be painted on a clear transparent sheet of celluloid, and then a foreground character painted on another sheet of celluloid. Then the frame would be photographed with the foreground sheet in top and the background sheet under it. This was efficient because for many of the photographed frames the background would not change. But you could change the foreground sheet to create animation with a series of new celluloid sheets and not have to keep repainting the static background.

Layers in GIMP work in a similar way but they can do a lot more. But if we stick with the metaphor for just moment longer we can make an important point: Once the cells had been stacked up and photographed, you could not easily edit the final photograph. If there was something wrong with the frame you would need to shoot a new one. But as long as you kept all the original cels, you could always make a change to one of the cels, then shoot a replacement frame. GIMP has analogous considerations. The equivalent of the cels is what we call Layers, and as long as you keep the layers distinct in your GIMP file you can always go back and make edits. But two things can mess you up if you are not careful, so here are a couple of rules to avoid “gotchas” in GIMP:

  1. Always keep your GIMP native file separate from your final output. GIMP native files are what you get when you click Save on the file menu, and they have the file extension *.xcf, which stands for eXperimental Computing Facility, which was the group at the University of California at Berkeley where GIMP was created. My own approach is to keep two sets of files, one of GIMP originals, the other of output files like *.jpg or *png. You get output files when you click Export, and those are like the photographed frame in animation that is no longer easily editable. (I say “no longer easily editable” rather than no longer editable because in rasterized images you can always edit them if you are willing to put in hours going pixel by pixel. I am not interested in doing that, however, and I doubt you would be either.)
  2. Resist using the Merge command if you aren’t certain of what you are doing. Merge will take those separate layers and combine them all into one image, again doing essentially what the photograph does in animation. You *may* be able to undo, depending on whether you have saved the file yet, but only by undoing everything you have done to go back to a point before you merged. Being the cautious type, even if I am going to do a merge, I would save a pre-merge copy of my file just in case I need to go back. We’ll cover doing Merges, but always keep this caution in mind.

Plug-ins

It should come as no surprise that GIMP has a variety of plug-ins available, and some of them should be useful for working with Layers. The best place to look for plug-ins now is through your distro repository. On my Kubuntu installation, I added the package gimp-plugin-registry. There used to be a such a registry within GIMP, then they decided to close it. It looks like maybe it will return in a different form someday, but for now getting this from my repo is the best bet. Install the package, then re-open GIMP, and you will see a few new menus appear, FX-Foundry and Script-Fu. Having these around should prove handy.

Transparency

The next concept you need to learn to use GIMP is transparency. Layers can use transparency in a variety of ways. Transparency is used in Layer Masks, and are most frequently found in backgrounds since they let you place elements like text on an image without obscuring other parts of the image. Again using our cel metaphor, the sheets of celluloid are transparent to begin with. When the artist paints an image on the cel, the image itself may be opaque, but the rest of the cel remains transparent, and that is why you can stack them to get the final image you want for the photographed frame.

A related concept in computer graphics is something called the alpha channel. Webopedia has a nice definition:

In graphics, a portion of each pixel’s data that is reserved for transparency information. 32-bit graphics systems contain four channels — three 8-bit channels for red, green, and blue (RGB) and one 8-bit alpha channel. The alpha channel is really a mask. It specifies how the pixel’s colors should be merged with another pixel when the two are overlaid, one on top of the other.

Typically, you wouldn’t define the alpha channel on a pixel-by-pixel basis, but rather per object. Different parts of the object would have different levels of transparency depending on how much you wanted the background to show through. This allows you to create rectangular objects that appear as if they are irregular in shape — you define the rectangular edges as transparent so that the background shows through. This is especially important for animation, where the background changes from one frame to the next.

Rendering overlapping objects that include an alpha value is called alpha blending.

https://www.webopedia.com/TERM/A/alpha_channel.html

The key point is that when you start working with layers you want to become comfortable with transparency. When you create an image, for instance, one of the options for the background is transparency. Go to File–>New, and then click the Advanced Options Drop-down. You will see this:

Advanced Options for a new Canvas.
Advanced Options for a new Canvas.

In the Fill with box, click the drop-down, and select Transparency. You will get something that looks like a grayscale checkerboard. That is a standard way of displaying what would otherwise be a transparent image for working with it. The default way of presenting this can be improved, however, by going into Preferences.

Preferences

The goody bin for most of the settings in GIMP is found in the Edit menu under Preferences. Clicking on that opens up this window:

GIMP Preferences Window
GIMP Preferences Window

There is a lot in here, and I don’t want to go into all of it now. I think it is better to go back here as needed, so I will cover the settings here as they come up. For the transparent background settings, go to Display, and the first thing you see is the Transparency settings. Personally, I set mine to Light Checks for the Check Style, and Small for the Check Size. Try it for yourself and see if that works for you. With these settings I can still see where the transparency is without having it overwhelm other objects like text or other image elements.

The other area in Preferences I will address right now is the Undo levels. This is reached through the first Preferences option, Environment. There are two key settings to look at, the number of levels, and the maximum memory allocation. Undo levels have to be stored in RAM, so if you increase the number of levels your RAM usage will go up. I try to get as much RAM as possible for my machines, but I don’t want to spend a lot of money on upgrades if I don’t need to. Right now my Kubuntu machine has a motherboard that only allows me to have 16GB of RAM, so that is how much I have for everything. Whenever I need to purchase a new motherboard I will certainly get one that lets me install 32GB of RAM, but for now this is working just fine. Even with only 16GB, though, I can afford to allocate more RAM, so I have multiplied both of those settings by 10. That gives me 50 Undo levels, and allocates 640MB of RAM, which I can certainly afford. You should check out what works for you, but I have always increased Undo levels in any software I work with. It just makes your life easier.

The Layer Tab

The final piece in our introduction is for the Layer Tab. This located in the upper right on a standard screen. (Remember, I went to the Windows menu and selected Single-Window Mode, but otherwise left everything in the default position. I recommend that while you are learning you might want to keep things in the default mode until you get more experience.) It is in the section above the Brushes, Patterns, and Gradients selectors we looked at previously. It is the first tab in this section, and looks like this:

GIMP Layers Tab

When you are working with Layers, you want to have this tab open. In the main area you will see each layer separately, and can click on any one to select it and make it active. This is useful for editing multiple-layer images. Mode is something that will require more attention later, but it essentially governs how multiple layers will combine into the final picture when you are mixing them together.

Lock has two buttons. The one that looks like a paintbrush is the “lock pixels” button and locks the entire layer. Next to it is the button with the checkerboard pattern that we know denotes transparency. This is the button to lock the Alpha channel. These buttons can be useful in a shared environment, for instance, to stop someone from changing your image.

At the bottom are more buttons. From the left, they are:

  • Create a new layer
  • Create a new layer group. Layer groups were added in GIMP 2.8, and allow layers to be linked as a unit. They will display in the window “tree-style”, with one layer on top and several sub-layers indented under it. This means you can move a group of layers as if it was one layer and still have the component layers separate.
  • Raise the layer
  • Lower the layer – Remember that layers are like transparent sheets, and what is on one layer can be partly obscured by one above it, just as with the animation the background sheet would be on the bottom, and the character sheet on top of it. Order of layers matters.
  • Create a duplicate of the layer – This is something you do frequently with many of the techniques in GIMP, such as for making masks.
  • Anchor a floating layer – GIMP lets you create temporary layers called “floating layers”, but before you can switch to working on a different layer you have to anchor the floating layer.
  • Delete the layer

So in this tutorial we have not only introduced layers, we have also introduced Plug-ins and the Preferences settings. That is a lot for one lesson, so we’ll end this here. But we have a lot more to talk about.

Listen to the audio version of this post on Hacker Public Radio!