Closed mn4367 closed 7 years ago
I tested both files also with Jimp and there were no problems loading them.
Hi, you must push your decoded result through UPNG.toRGBA8 before encoding it again, I have added an example at the main page.
PNG images with two colors may use 1 bit per pixel. UPNG.decode() returns pixel data in this original form. Some users may want to keep the data in this form, instead of converting them to RGBA8 (which would make the image 32 times bigger in this case - four bytes per pixel). That is why I separated the decoding into two steps.
Do you think we should convert to RGBA8 right inside UPNG.decode() ? Also, PNGs can have 16 bits per channel sometimes (8 bytes per four-channel pixel), so after converting them to RGBA8, the quality would be lost. 16-bits PNGs can not be encoded by UPNG.js yet.
Hi, you must push your decoded result through UPNG.toRGBA8 before encoding it again, I have added an example at the main page.
Ah OK, now it works, thank you very much!
Do you think we should convert to RGBA8 right inside UPNG.decode() ? Also, PNGs can have 16 bits per channel sometimes (8 bytes per four-channel pixel), so after converting them to RGBA8, the quality would be lost. 16-bits PNGs can not be encoded by UPNG.js yet.
Wouldn't this compromise a bit of the flexibility since the output of decode would then be always RBGA8? And with regard to the "auto-loss" with 16Bits this isn't a good solution, I think.
At least for my use case I don't need it, but other users may think different.
Thanks again!
Ok, I will keep it as it is.
I tried to create a Node.js module from UPNG.js. To do so I added
as the first line and
as the last line in
UPNG.js
.Then I loaded
pug.png
from the samples page at https://blog.photopea.com/png-minifier-inside-photopea.html. The following code was used (running in Node.js):I receive the following error:
With another test file (attached zip) I get:
and the resulting file has scrambled content.
Archive.zip