yoga icon indicating copy to clipboard operation
yoga copied to clipboard

Grayscale encoding mode

Open nekohayo opened this issue 1 year ago • 3 comments

This is a bit of a corner case, but it is useful for massively shrinking size further when dealing with scanned documents, especially text or some types of drawings: the ability to force the image to be in grayscale instead of RGB color. Oftentimes, document scanning apps (or people who do the scanning) may not think (or know) to encode that way, so the image is imperceptibly color even though perceptually it is grayscale. Converting to grayscale, for PNG and other lossless (or lossy) formats helps a ton... but doing it one image at a time with GIMP is a pain in the butt.

The same rule applies to alpha channels: sometimes there is one even if you don't necessarily need it, and it's extra weight that could be discarded (if the user knows what they're doing :)

nekohayo avatar Feb 19 '23 13:02 nekohayo

For the Alpha channel, it should already be removed if it not used. If you ever find a picture with an unused alpha channel that is kept after encoding, please open a bug with the image and the selected options so I can check and fix it :)

flozz avatar Feb 19 '23 16:02 flozz

Oh wow that's amazing. I didn't know it was easy/possible to autodetect the relevance of alpha channels!

nekohayo avatar Feb 19 '23 17:02 nekohayo

It is easy to know if it is not used at all. For that, you have to look at each pixels: if the value of the alpha channel is 255 it means the pixel is opaque; and if all pixels are opaque, there is no need of an alpha channel :)

flozz avatar Feb 19 '23 17:02 flozz