Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grayscale encoding mode #46

Open
nekohayo opened this issue Feb 19, 2023 · 3 comments
Open

Grayscale encoding mode #46

nekohayo opened this issue Feb 19, 2023 · 3 comments

Comments

@nekohayo
Copy link

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 :)

@flozz
Copy link
Member

flozz commented Feb 19, 2023

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 :)

@nekohayo nekohayo changed the title Grayscale encoding mode, and ability to discard alpha channel Grayscale encoding mode Feb 19, 2023
@nekohayo
Copy link
Author

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

@flozz
Copy link
Member

flozz commented Feb 19, 2023

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants