-
Notifications
You must be signed in to change notification settings - Fork 59
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
Png encoding using upng.js techniques #77
Comments
@twoxfh thanks for pointing out this.
Wen |
@dragon66 ``
|
@twoxfh I am not sure what you mean by "restrict colors and converts to rgba8." If you want to restrict colors for the purpose of smaller image size, why do you want to convert to rgba8? ICAFE can save PNG images as indexed-color (with single color transparency), true-color (with or without alpha - alpha channel transparency) or grayscale. To save lossless images, use true-color; to save lossy images, use indexed-color. The example you provided actually will save the PNG as indexed-color. There are a couple of image parameters which are not actually used at the moment by icafe. The componentColorPalette is one them. So is the rgbColorPalette. The reason for this is the color palette itself is automatically created either during the color quantization process or through the color checking process in the case that the original images contain less than 256 colors. For the bitsPerPixel parameter, the current implementation will only reduce the colors to 256 (bitsPerPixel = 8) if the original image contains number of colors more than 256. If it contains number of colors less than 256, icafe will automatically determine the smallest bitsPerPixel required to save the image as indexed-color. I have done a small change to actually take this parameter into effect so quantization can actually reduce colors to less than 256. You can try play with the bitsPerPixel parameter to reduce your image size while saving to indexe-color image. The effective bitsPerPixel is 1, 2, 4, 8. Another thing you can do is actually disable quantization but that may introduce noticeable artifacts into your output images. |
Thank you for your feedback, been very helpful. Not sure if you want to close this issue or keep it open for UPNG.js review. If I come up with any code worthy of a pull request, will submit. |
Thanks! Keep it open. I am also looking and comparing the results of ICAFE and UPNG to see what I can do to improve ICAFE. |
I have done a systematic comparison of the indexed color PNG images created by tinyPNG, UPNG and ICAFE. The images generated by ICAFE are usually a few KB larger than tinyPNG and more larger than UPNG. It is not a very big deal to me given those tools are specifically created for PNG optimization purpose. One thing that does need to be addressed for ICAFE is the quantization process which does not handle well full alpha transparency for indexed color images as it was intended to address single color transparency like GIF. Another thing I noticed is that there is no dithering process for UPNG which makes it easier to handle transparency. ICAFE on the other hand, has both diffusion and ordered dither support which makes it difficult to handle transparency. I did some experiment and it seems promising to include full alpha management. Will update and close this issue when I finish updating the code to fully address this issue. Further optimization for ICAFE to squeeze out a few KB per image is not a priority for me at the moment. |
I created png's with this great library and thought it was very compact. I then took the output and used upng.js and was abile to save an additional 20 to 30 percent without noticable quality loss. I don't have the expertise to implement what they did in Java, however, maybe someone else does. Would be a nice addition to this or its own library. Http://GitHub.com/photopea/UPNG.js
The text was updated successfully, but these errors were encountered: