You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When loading 8-bit grayscale PNGs with Pillow, and converting them to RGB, they are converted like if they were 1-bit PNGs.
So basically, white,lightgrey,midgrey,darkgrey,black becomes white,white,white,white,black.
For now I'm implementing a workaround by converting all PNGs to lossless WebP as a transient format because cwebp is known to properly convert PNG to lossless WebP before loading the bitmap with Pillow.
For example I do PNG to WebP to TGA to convert from PNG to TGA.
This becomes crazy because we already did PNG to TGA to CRN to convert from PNG to CRN because crunch doesn't read all PNG formats. So, since we cannot do PNG to TGA in one go, I now do PNG to WebP to TGA to CRN to convert from PNG to CRN. This is really crazy!
Some code may now be highly unoptimized like PNG to WebP since the sanitization of the image is converted first to WebP before being converted to WebP again.
I plan to introduce a specific ImageConverter module to handle image conversion properly with the “shortest” (ahem) path for known formats.
This workaround is good enough to build Unvanquished 0.54 release.
Note: in the past we used ImageMagick convert tool to convert from anything to TGA but then ImageMagick broke TGA conversion (both conversion from TGA and to TGA) and maintainer is considering there is no bug, so this other tool is not an option anymore.
Something is wrong with PNG…
The text was updated successfully, but these errors were encountered:
illwieckz
changed the title
Pillow doesn't support 8-bit grayscale PNG properly
Pillow doesn't properly support 8-bit grayscale PNG
Jan 29, 2023
See #61
When loading 8-bit grayscale PNGs with Pillow, and converting them to RGB,
they are converted like if they were 1-bit PNGs.
So basically, white,lightgrey,midgrey,darkgrey,black
becomes white,white,white,white,black.
For now I'm implementing a workaround by converting all PNGs
to lossless WebP as a transient format because cwebp is known
to properly convert PNG to lossless WebP before loading the
bitmap with Pillow.
For example I do PNG to WebP to TGA to convert from PNG to TGA.
This becomes crazy because we already did PNG to TGA to CRN to convert
from PNG to CRN because crunch doesn't read all PNG formats. So, since
we cannot do PNG to TGA in one go, I now do PNG to WebP to TGA to CRN
to convert from PNG to CRN. This is really crazy!
Some code may now be highly unoptimized like PNG to WebP since the
sanitization of the image is converted first to WebP before being
converted to WebP again.
I plan to introduce a specific ImageConverter module to handle
image conversion properly with the “shortest” (ahem) path
for known formats.
This workaround is good enough to build Unvanquished 0.54 release.
When loading 8-bit grayscale PNGs with Pillow, and converting them to RGB, they are converted like if they were 1-bit PNGs.
So basically,
white,lightgrey,midgrey,darkgrey,black
becomeswhite,white,white,white,black
.For now I'm implementing a workaround by converting all PNGs to lossless WebP as a transient format because cwebp is known to properly convert PNG to lossless WebP before loading the bitmap with Pillow.
For example I do PNG to WebP to TGA to convert from PNG to TGA.
This becomes crazy because we already did PNG to TGA to CRN to convert from PNG to CRN because crunch doesn't read all PNG formats. So, since we cannot do PNG to TGA in one go, I now do PNG to WebP to TGA to CRN to convert from PNG to CRN. This is really crazy!
Some code may now be highly unoptimized like PNG to WebP since the sanitization of the image is converted first to WebP before being converted to WebP again.
I plan to introduce a specific ImageConverter module to handle image conversion properly with the “shortest” (ahem) path for known formats.
This workaround is good enough to build Unvanquished 0.54 release.
Note: in the past we used ImageMagick convert tool to convert from anything to TGA but then ImageMagick broke TGA conversion (both conversion from TGA and to TGA) and maintainer is considering there is no bug, so this other tool is not an option anymore.
Something is wrong with PNG…
The text was updated successfully, but these errors were encountered: