Mask from alpha channel is wrong
GIMP version: 2.10.20
Operating System: Linux
Package: https://www.archlinux.org/packages/extra/x86_64/gimp/
Description of the bug
I want to create a premultiplied PNG to use it in a glsl shader with premultiplied alpha blending. Because there is no option “premultiply” in PNG export dialog (please add this option), I wanted to manually multiply the color channels with the alpha channel. I tried to extract the alpha channel, but the resulting alpha was always to bright. My reference is Photoshop with SuperPNG plugin and imagemagic (“convert in.png -background black -alpha Remove in.png -compose Copy_Opacity -composite out.png”) to get a right premultiplied image.
Reproduction
Reproduction steps:
- Open unpremultiplied image with transparency
- right-click on the layer →Add Layer Mask.. → check Layer’s alpha channel → add. Now you can already see, that the mask is much brighter than the alpha channel preview in the channels panel
- right-click on the layer →show layer mask
- select everything, copy it to the clipboard
- create new layer and paste the copied mask to it
- set “Mode” to multiply
- delete Mask from the first layer
Again, an option to multiply on export would be so helpful. Unchecking “Save color values form transparent pixels” also gave me wrong results.
Expected result:
Image with color channels that are multiplied with the alpha channel. The Mask created from alpha channel is exact the same as the alpha channel.
Actual result:
Colors are to bright, because the extracted alpha is wrong.
Workaround:
- set the layers Composit space to RGB (perceptual)
- alpha to selection
- remove alpha channel. This also applies alpha to color ( #3978 ) , this should be a separate function.
- add layer Mask from selection