0

Does anyone know how Remove Alpha Channel works and what Flatten Image exactly does (e.g. what operations it performs and in what sequence)? In particular, I'm trying to understand why they produce different results on a 1x1-px (single-layer) image with the following RGBA values for its only pixel: 78:69:128:254. Remove Alpha Channel produces a pixel with RGB values 79:70:128 while Flatten Image produces a pixel with RGB values 79:70:129. This was tested on GIMP 2.6.10 and 2.8.14. The background color specified in the toolbox was white (RGB values 255:255:255) in all tests.

EDITS

  • added information about the background color
2

Flatten image squashes all layers over a virtual opaque background filled with the background color, so the RBG values of the result depend on the current background color.

  • Have you tested your hypothesis? – SJU Jul 12 '17 at 6:47
  • Yes. Easy to test... Did you try yourself? – xenoid Jul 12 '17 at 6:51
  • Then could you describe what you tried and what happened? – SJU Jul 12 '17 at 7:59
  • Make a yellow layer (255,255,0), use a layer mask to set opacity to 50%. Set background color to red (255,0,0). Flatten image, as expected, the result is orange and corresponds to what I get if I add a red layer under the half-transparent yellow layer. And you? – xenoid Jul 12 '17 at 9:23
  • I could be convinced that this example supports the point that 'Flatten image squashes all layers over a virtual opaque background filled with the background color' but I asked for a TECHNICAL explanation how Flatten Image works. Also, I don't see how the example supports the hypothesis that Remove Alpha Channel DOES NOT affect the RGB values. My observations say otherwise (see my question for a test case) and I asked if anyone could explain (again, in technical language) how Remove Alpha Channel works. – SJU Jul 12 '17 at 10:54
0

Definitions from the doc:

  • Flatten image: If there are any areas which are transparent through all of the layers of the original image, the background color is visible.. So this would be the same as adding a background layer and merging down.
  • Remove alpha channel: If the active layer is not the background layer, transparency is replaced with the background color of the Toolbox. Which is the description I would have used for bucket-filling in behind mode.

So, there are several operations that ought to all produce the same result:

  • Bucket fill white in 'Behind' mode
  • Merge down over white background
  • Pointer tool with "Sample merged" over white background
  • Flatten image with white background:
  • Flatten image without white background:
  • Remove alpha channel

Experimentation with 78:69:128:254:

* Bucket fill white in 'Behind' mode:              78:69:128
* Merge down over white BG:                        78:69:128
* Pointer tool with "Sample merged" over white BG: 78:69:128
* Flatten image with white BG:                     79:70:129
* Flatten image without white BG:                  79:70:129
* Remove alpha channel:                            79:70:128

The first three are consistent, #4 is surprising because it doesn't produce the same result as #2.

Using a less extreme opacity value, experimenting with 78:69:128:200:

* Bucket fill white in 'Behind' mode:              116:109:155
* Merge down over white BG:                        116:109:155
* Pointer tool with "Sample merged" over white BG: 116:109:155
* Flatten image with white BG:                     116:109:155
* Flatten image without white BG:                  116:109:155
* Remove alpha channel:                            116:109:155

Here all give the same result.

So, there are likely slightly different methods (flattening the image could take some shortcuts) differently impacted by round off errors (yes, I know this is not an answer, but it shows some methods that always give the same result).

  • Doesn't test #6 give surprising results (in the first round), too? What version of GIMP did you carry out your tests with? – SJU Jul 13 '17 at 9:52
  • Yes, but you had already found that one out. Using 2.8.22 Linux. – xenoid Jul 13 '17 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.