Done using GIMP 2.10.20 on Kubuntu Linux 18.04 LTS
Digital image editing is a process whereby mathematical expressions produce something you can look at. When it is done in a raster-type program such as GIMP, this means that each pixel has numbers that represent the 4 possible channels (Red, Green, Blue, and Alpha), and those numbers determine how that pixel will appear in the image. A vector-based program like Inkscape, in contrast, uses equations to define overall elements in the image. These two approaches mean that each program has strengths and weaknesses, so you would be well advised to choose carefully. For example, if you are creating an image that you want to resize at will without a loss of clarity and sharpness, you really have to do it in a vector-based program. The equations don’t care about scale. However, a vector-based program cannot reproduce photographs well, since photographs are inherently raster-based.
Now, because GIMP is raster-based, it is great for working with photographs, and you can make use of the mathematics to manipulate the pixels, which is what GIMP does, in essence. And one excellent example of this is the ways you can blend layers. Since the individual pixels are just numbers, you can write algorithms to combine them in different ways. One of the simplest is by making use of the Opacity control on each layer. To illustrate this, lets again go looking for images we can use freely. I went back to the Wikimedia site to find another repository of free images, and I found one that looked interesting, The Famous Artists. These are digital images of art works created in previous centuries and are all in the public domain. I decided to download an image of a painting by the Korean artist Jeong Seon (1676-1759). It is a painting of a famous mountain in what is now North Korea, and the painting is titled Geumgang Jeondo or “General view of Mt. Geumgangsan”.
To illustrate what you can do, I opened this picture in GIMP 2.10.22, the latest version as I write this. Since this image is a *.jpg and I wanted to work with transparency, I first had to add an Alpha channel, which I did by right-clicking on the layer in the Layers window, and clicking Add Alpha Channel in the pop-up window. Next, I created a second layer, which I named “Background”. This layer is the exact same size as my original image, of course, which makes this easy. Now I turned to my Gradients panel and selected “Yellow-Orange”, and filled my new layer with this gradient. I made this new layer my top layer, which meant I could not see any of the painting. But by reducing the opacity of this layer using the slider at the top of the Layers window to 35%, I got a nice combination.
Of course you can get something very similar if you put the painting layer on top and the reduce it’s opacity to around 65%.
This type of blending is pretty straightforward, and not too complicated. But you can do more, and that brings us to the topic of Layer Modes.
Layer Modes
In GIMP 2.10 there are 38 layer modes (sometimes also referred to as Blending Modes), sorted into seven different groups:
- Normal
- Lighten
- Darken
- Contrast
- Inversion
- HSV components
- LCh components
Now, if you check the GIMP documentation for GIMP 2.10, you will discover that a number of these modes are not documented. The 21 modes in the previous version, 2.8, are documented, but not the new ones. That poses a problem for this tutorial since I cannot see the precise equation or algorithm used in these particular modes. However, there are some good resources available, including some YouTube videos and Web sites:
- GIMP 2.10 Tutorial: All Layer Modes Explained
- How to Use Blend Modes on Layers | GIMP 2.10 Tutorial 2018 / 2019
- A tutorial on GIMP’s very awesome LCH Blend Modes
There is also a good general discussion of the concepts and mathematics of this on Wikipedia. This is not a detailed documentation of each mode, nor is it limited to GIMP since Photoshop modes are covered. So this is a good theoretical background to how these blending modes operate.
As with other operations, these modes use equations to determine how to combine two layers on a pixel by pixel basis. The mode is set on the top layer, and defines the combination with the layer below it. So of course you need two layers to accomplish anything. To illustrate how this works, I first need some images. I thought I would try the Creative Commons site of freely reusable images, and while I was there I made a small donation to support their work. As my friend Door-to-door Geek likes to say, support the people who support you.
This site has works under a variety of CC licenses, but you can filter the search results by license type, so just to be safe I filtered on CC0 licenses, and grabbed a picture of a dog, because I really like dogs:
Then, for some contrast, I found an image of some toys figures:
Note that while I specifically looked for CC0 licensed images, I still am crediting the artist on both of these. There is really no reason not to do so. I prefer CC0 simply because I know I won’t accidentally violate a license, but I fully support crediting the artist
My next step is bringing these images into GIMP. These images don’t have exactly the same dimensions, and in either case are somewhat larger than what I want to work with. So I first created a new image in GIMP with the dimensions of 480×480. This was just a blank white square because I only need it for a moment. Then I opened both of my downloaded images as layers (File–>Open as Layers) which automatically crops the images to fit the existing image at 480×480. And what is even neater is that you can use the Move tool to move the image around to get the crop the way you like it. This is definitely good. Once I had the cropping I liked, I duplicated each of the images, and locked the duplicate to prevent moving or pixel editing, including the Alpha channel. This is my backup in case something goes wrong. And while I don’t really need that blank layer any longer, I will just turn off the visibility of it, and also of my locked duplicates. Then, just to sure I don’t accidentally move my cropped images, I will lock them against moving. (Note, these locks appear on the Layers tab above the layers. You select a layer, then apply the locks you want. You can always see which locks are applied to a layer by selecting the layer and seeing which buttons are pressed.)
Now I have these two images ready to use as examples for illustrating Layer Modes.
Normal modes
The first group is the Normal modes:
- Normal
- Dissolve
- Color Erase
- Erase
- Merge
- Split
Normal Mode
The simplest of these is the default, Normal. This is what GIMP has been doing for you all along if you never changed the mode. In Normal, the Top layer covers the bottom layer, but if there is any transparency in the top layer some of the bottom layer will show through. Now to some terminology. The Top layer is also known as the Blend layer, the Active layer, or the Mask layer. The GIMP documentation calls it the Mask layer. The Bottom layer is also known as the Base layer or the Image layer, and the GIMP documentation favors Image layer. But I like to use Top and Bottom for clarity.
In the GIMP documentation they use some relatively straightforward mathematics to show how these modes give you a layer blend. For each pixel, you have four channels: Red, Green Blue, and Alpha. Then you can give the values in each channel as a number between 0 and 255, i.e. 8 bits per channel. For Red, Green, and Blue, 0 represents no amount of the color, and 255 represents the maximum amount of the color. So (0,0,255) would be purse Blue, (0,255,0) would be pure Green, and so on. For the Alpha channel, full transparency is 0, and full opacity is 255. What the program does in an image is combine the 4 numbers for each pixel in some way. The GIMP documentation gives this simple example: E=M+I. This would simply add the numbers, so if the Top image (M) had a pixel with the value (100, 210,104,255) and on the Bottom layer (I) the corresponding pixel had the values (75,108,97,0), you would just add the numbers in each position to get (175,318,201,255). Then because 255 is the maximum, the green value is reduced from 318 to 255, and now it is (175,255,201,255).
In looking at the Normal mode, the GIMP documentation says the equation is E=M, in other words, only the Top layer shows in the final result. But I think this is overly simple, since it ignores the effect of the Alpha channel. If you have applied some transparency to the Top layer, then whatever is on the Bottom layer will of course come through to some degree. I think that what they meant by that is that the Layer mode itself does not add any effect to the result, which makes their equation true in that way.
With all of this background on Layer Modes, we can now look at them in the coming tutorials.