# GIMP Compositing Modes by Seth Kenlon When GIMP released its first major update in five years from 2.8 to 2.10, it was revealed that the compositing menu had undergone some significant changes. All the usual ones were there, but so were a whole screen-full of new ones. In addition to that, there's a Blend Space, Composite Space, and Composite Mode for each layer. Compositing can be confusing, and the GIMP documentation doesn't explain the different modes, so I sat down to trial each composite mode, one my one. For this demonstration, I have left All layer options (Blend Space, Composite Space, Composite Mode) set to their default values. For my test, I used two Creative Commons test images, one by [Vox Efx](https://flic.kr/p/dtnj6) [CC BY 2.0](https://creativecommons.org/licenses/by/2.0/) and one by [Chris Hunkeler](https://flic.kr/p/eUfJqC) [CC BY-SA 2.0](https://creativecommons.org/licenses/by-sa/2.0/). These photos are combined with an series of solid black, gray, and primary colour bars. There's also a patch of alpha to help expose any effect that the white opaque background has on the results. The only layer changing composite modes in these tests are the top layer, containing horizontal (lateral) bars of 50% gray, black, and white. Test images and vertical bars are flattened into one layer. The white and alpha background is on a third layer. ## Standard set The first options deal largely with the alpha channel, in a variety of ways. You can think of *alpha* as the colour of invisibility, or *nothing*, but by varying degrees. Alpha isn't black or white, but actually the absence of colour. If alpha were something in the real world, you might say that a freshly washed window is 99.9% alpha. A darkened glass might be called 80% alpha. In computer graphics, it's a sort of tradition to represent alpha as a gray checkerboard, and in video it's often bright green that gets swapped out for alpha (in the green screen process). In other words, alpha is often the "gaps" between pixels that are actually occupied with color (chroma) and brightness (luma) information. ### Normal ![Normal](normal.png) The normal compositing mode for GIMP is essentially a union blend, showing you the topmost pixel in layer order. In other words, the horizontal bars in the top layer of the test image "cover up" anything in a lower layer, while pixels containing 100% alpha is fully transparent and has no effect on the layer below it. This means that **Normal** compositing in GIMP, as with most graphic and video applications, does not indicate that there is no compositing, because to "see through" the alpha channel, the layer below it (or that ubiquitous gray checkerboard pattern) must be composited into your view. ### Dissolve The dissolve blend mode is less a dissolve effect than an anti anti-alias, or a scatter effect. It is most visible when applied to gradients. For example, on the left in this sample image is a smooth red gradient one layer above a white background. On the right, the red layer is set to a dissolve blend. ![Dissolve](dissolve.png) The effect is more pronounced the more fall-off there is between alpha and chroma, but any time there's aliasing done in a digital graphic, you can generally see results. Here's a close-up of the test image: ![Dissolve](dissolve2.png) ### Color erase ![Color erase](color-erase.jpg) The color erase blend mode is new in GIMP 2.10. Chroma pixels of one layer are compared to the chroma pixels of another. The less the delta between the pixels (meaning they are similar in value), the more they are converted to alpha, which in effect erases pixels by color. Pixels that are perfect matches are removed entirely, which explains the stair-step sequence of alpha blocks in the lower right bars: as bars of exactly the same values overlap, the intersection is "erased". ![Color erase](color-erase-detail.jpg) This also explains why the colors intersecting skin tones are converted to their complimentary counterparts; similar chroma values are being filtered out, resulting in whatever color remains without the removed values. For instance, skin tones tend to have an amber, or orange-reddish hue. If you filter out the amber hue by combining it with a red color bar, then the values that remain lean heavily toward green and blue. ### Erase ![Erase](erase.jpg) The erase blend mode implements absolute negation of intersecting chroma. If two color values intersect, they are replaced with alpha. According to the source code, this blend mode multiplies the layer's current alpha by the layer's opacity (which is 100% in my tests). It behaves differently if a layer mask is present, and makes allowances for different layer composite modes, but I did not test all possible combinations, and in the end I was unable, from a user's perspective, to distinguish erase from split. ### Merge Merge has the same result, at least in my tests, as Normal. The source code reveals that merge mode sets the output alpha differently what normal mode does, but at least in my simple tests, I was unable to produce anything unique between the two modes. ### Split Split has the same result as Erase, at least visually. Technically, split treats alpha differently than erase does: ignoring the possibility of special layer masks, the layer's alpha is set to its starting alpha value minus the alpha it is compositing against. However, in practise, I was unable to detect any difference between this and the erase blend mode. ## Lightening set The next section of modes lighten an image. ### Lighten ![Lighten](lighten.jpg) The lighten blend mode analyzes each color channel of intersecting pixels, and displays the lighter value. For instance, in my test image, the whites of the models' eyes are preserved because they are lighter than the color bar overlaid on top of them. In shadow areas, or in dark hair, the value of the color bar is often lighter, so the shadaw is boosted by the color. Even more interesting things happen when two primary colors intersect. The intersection of the red and green bars produces yellow. If you're accustomed to physical media, like paint, this is not at all intuitive, but if you can [think in hexadecimal](LINK TO MY HEXADECIMAL ARTICLE), it makes perfect sense. The hexadecimal value of red is ff0000 and the hexadecimal value of green is 00ff00, and taking the brigher values (f in hex is 16, which is higher than 0) from each produces ffff00. ### Luma Lighten ![Luma Lighten](lighten-luma.jpg) While the lighten mode looks at color channels as a basis for comparison, luma lighten uses the luma value of each pixel. *Luma*, in digital imagery, refers to the brightness of a pixel. A white pixel can be said to have a luma value of 1.0, while a black pixel has 0. In luma lighten mode, the brighter luma value decides the "winner" of the comparison. You can see this in the test image in a few places: without taking a light reading, you can probably tell that the red bar is brighter than the male model's eyebrows, for instance, and that's why his eyebrows are displayed as red. You can probably also guess that the green bar is brighter than the red bar, and so when green and red intersect, green wins. ### Screen ![Screen](screen.jpg) Like the lighten modes, screen always results in a lighter color, because it inverts the color values in each layer, and then multiplies those values together. Math is hard enough without resorting to multiplying hexadecimal values, but you can get a good idea of the proof by looking at the results of chroma (color) against the absolute values of black (0) and white (f). The black bar on the far left of the test image is converted 100% to the color overlapping it, while the white parts of the page drop 100% of the color. This makes sense because the chroma values of the layers are being multiplied against their inversed values, meaning that any color multiplied against black is actually being multiplied by a full value, and a color multiplied by white is being multiplied by 0. ### Dodge ![Dodge](dodge.jpg) In traditional photography, prints were made in a darkroom because the emulsion used to create a paper copy of the photo was sensitive to light. Photographers found that they could make part of an image brighter by blocking some of the light causing the emulsion to take on the properties of the film negative. The dodge mode in GIMP emulates that principle as applied to color channels. Dodge mode brightens the layer in normal mode by decreasing the contrast between it and the compositing layer. A dodge blend against black (essentially a null value) renders black. You see this in the test image prominently in the models' faces under the green bar. Facial details are visible, but they are strongly green because the pixels in the face have been modified to be closer to the value of the green bar. It's more pronounced in the male model because of his dark skin tones, while the female model's lighter skin means less adjustment is required to minimize contrast. ### Addition ![Addition](addition.jpg) With addition, the the base layer's color is brightened by the value of the composite layer. An addition blend against pure black renders the composite color because 0 plus any integer is that integer. An addition bled against white remains white because white is already a maximum value (ffffff). You can see this mode most in the color bars on the right. The gray bar becomes more red, blue plus red produces purple, and so on. The red bar remains red because its values are absolute in this example: ff0000 plus ff0000 can only result in ff0000 because ff is already a maximum value, and 0 plus 0 produces 0. ## Darkening set The next set of modes darken images. ### Darken ![Darken](darken.jpg) The darken blend mode analyzes intersecting pixels, and displays the darker value (using the ``MIN`` function in C on each color channel of each layer). For instance, in my test image, the whites of the models' eyes are replaced with red because they are lighter than the color bar overlaid on top of them. In shadow areas, or in dark hair, the value of the color bar is replaced by the darker pixel. You might be confused to find that red on green produces black instead of red (the darker shade between the two colours). The reason for this is that the resulting colour is an amalgamation of the darkest values of all three colour channels. If you select the lowest number from ff0000 and 00ff00, you end up with 000000, which is black. ### Luma Darken ![Darken](darken-luma.jpg) While the darken mode looks at color channels as a basis for comparison, luma lighten uses the luma value (brightness) of each pixel. In luma darken mode, the darker (lower) luma value between two intersecting pixels gets displayed. All color bars have less luma than white, so the color bars in the test image are visible against the white and alpha backgrounds. When comparing colors to colors, the red color bar usually gets displayed except when compared to black. The color bars compared to the models has greater variety in results, with green losing out in all but the most pale regions. ### Multiply ![Multiply](multiply.jpg) The multiply blend mode analyzes the color information *in each channel* and multiplies the normal layer's color by the composite layer's color, resulting in a darker color. For this one, the math may be easier to think about in decimal: for each channel, a pixel may be anywhere from 0 to 1, meaning that any thing less than 1 is fraction of 1. For instance, if a pixel with .25 red is multiplied by a pixel with 1 red, the result is .25. You can can see this best in the color bars in the lower right corner of the test image. The vertical gray bar is darker at each intersection of gray, red, green, and blue horizontal bar (each of which are in turn darker than their origins). Pure colors are unchanged, because the only math happening is 1 times 1 for the channel containing a non-zero value. However, the blue bar has a little more variation in it, and so when it overlaps itself or green, the result is darker. The effect over skin tone mimics a color gel. Everything is washed and deepened by the color placed over it. ### Burn ![Burn](burn.jpg) Like the dodge mode, burn takes its name from a traditional darkroom technique. It's the opposite of dodge: instead of blocking light, it intentionally intensifies it, resulting in a darker exposure. In digital imagery, this means taking the color value in each channel and increasing the contrast (by darkening the pixel) between it and the value of the composite layer. The result is therefore darker. Doing this against white produces no change because of some hard-coded math (if you read C code, refer to **gimpoperationlayermode-blend.c** for details) that essentially negates white from the process, which is true to the darkroom analogy. Burning something that is already as light as possible (or, in terms of the negative being illuminated, as dark as possible) produces no change. Like multiply, you can see the effect of this blend mode in the color bars and in the skin tones of the models. In an image with bright highlights, as with the male model, this is an inelegant effect, but in something "flatter" (as with the female model photo), it produces some interesting manipulation of contrast ratios that would be difficult for you to change manually. ### Linear burn ![Linear burn](burn-linear.jpg) The linear burn effect does the same thing as the burn mode, except that instead of increasing the contrast, it just reduces the luma (brightness) of the normal layer compared to the compositing layer. It seems like a subtle difference, but it's a signifacnt change in the results. You can see from the test image that the color bars retain their integrity against white, and the white highlights in the male model's photograph smoothly take on the overlaid color. ### Overlay ![Overlay](overlay.jpg) This mode applies either a multiply or screen effect, depending on whether the pixel in the base layer is darker or lighter than the compositing pixel. The effect is that a composited color is able to effect the base layer while preserving its highlights and shadows. You can see this best in the vertical blue bar on the far right of the test image. The bar is bue throughout, but where the horizontal bars intersect with it, the shade of blue changes: sometimes it is darker and other times it is lighter. Similarly, you can see how gentle the overlay is on skin tones compared to the burn blend mode, creating a smooth falloff in the highlights. /home/sek/code/gimp-master/app/operations/layer-modes/ ### Soft light ![Soft light](soft-light.jpg) ### Hard light ![Hard light](hard-light.jpg) ### Vivid light ![Vivid light](vivid-light.jpg) ### Pin light ![Pin light](pin-light.jpg) ### Linear light ![Linear light](linear-light.jpg) ### Hard mix ![Hard mix](hard-mix.jpg)