Code Monkey home page Code Monkey logo

Comments (4)

mn4367 avatar mn4367 commented on June 6, 2024

I tested both files also with Jimp and there were no problems loading them.

from upng.js.

photopea avatar photopea commented on June 6, 2024

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.

from upng.js.

mn4367 avatar mn4367 commented on June 6, 2024

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!

from upng.js.

photopea avatar photopea commented on June 6, 2024

Ok, I will keep it as it is.

from upng.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.