photopea / UPNG.js

Fast and advanced PNG (APNG) decoder and encoder (lossy / lossless)
MIT License
2.1k stars 259 forks source link

Add support for 8-bit data export #36

Closed chrilith closed 5 years ago

chrilith commented 5 years ago

Hi,

Currently, decoding a PNG only returns a true color buffer, even if the file content is palette indexed.

It would be great to be able to optionally decide to get an array of color indices instead of an RGB array when there is a palette. And also get the Related palette of course!

It is important for me to keep the file intact when opening/saving back. Keeping depth etc.

Would this be possible?

Thanks! Chris

chrilith commented 5 years ago

OK this is already the case... was testing with a 24bit file sorry :)

Love this lib 👍

photopea commented 5 years ago

Hi, please use UPNG.toRGBA8() to convert any decoded PNG into RGBA 8-bit per channel.

UPNG.js guarantees, that the saved content would be the same (same width, height and color of each pixel), but it can not guarantee the same file size or internal representation (palette, grayscale etc.).