grayscale mode image, export as png with 8bpc GRAYA has 32 bits per pixel
Environment/Versions
- GIMP version: 2.10.36 (and some version from 2019)
- Package: Installer from gimp.org
- Operating System: Windows7
Description of the bug
-
Exporting "gimp" grayscale image mode as PNG 8bpc GRAYA results in 32 bits per pixel
-
I discovered the issue while reading the PNG images into cv2, and found that the array shape included 4 channels instead of the expected 2
Reproduction
Is the bug reproducible? always
Reproduction steps:
- load a color image (jpg, or png were tested)
- convert to grayscale (image->mode->grayscale)
- select a part of the image, goto layer, mask, add mask, and from selection
- goto layer, transparency, add alpha channel
- export as png, select pixel format 8bpc GRAYA
Expected result: 16 bits per pixel
Actual result:
- 32 bits per pixel.
- Using imread from CV2 returns an image array.shape of (x,y,4) instead of (x,y,2)
Additional information
-
Exporting as PNG 8bpc GRAY (no alpha) results in the expect 8 bits per pixel in the PNG file
-
Steps 3 and 4 are my effort at making an alpha channel (no idea what I'm doing), however I would expect that following steps 1,2, and 5 should also result to be 16 bits per pixel (as the alpha chan would be all 255?)
-
I've seen it said that "you can't have just a gray + alpha channel". However, wikipedia for PNG shows this to be allowed combination. Pedia PNG description (The color type field should have a value of 4 for the gray+alpha combination)
-
"PNG supports palette-based images (with palettes of 24-bit RGB or 32-bit RGBA colors), grayscale images (with or without an alpha channel for transparency),"
If you have a backtrace for a crash or a warning, paste it here.