-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
How to control png chunks generation? #1627
Comments
There's no way to control that from node-canvas. Your best bet would be to use |
Thanks for your answer. When use |
The PNG encoder code starts here if you want to take a look: https://github.com/Automattic/node-canvas/blob/master/src/PNG.h#L96 and the indexed image code is here: https://github.com/Automattic/node-canvas/blob/master/src/PNG.h#L216 The palette is expected to be an array of RGBA and it does write Without changing the Canvas API we could support I'm low on time to make any of these changes anytime soon, but can review PRs for them.
This would just be raw palette indices without encoding. If you add the chunk header and crc, that's basically IDAT. |
Thanks for being responsive. Unfortunatelly, using alpha: false completly removes PLTE (png is not indexed anymore) nor setting null as backgroundIndex changes anything. The same goes to On the other hand I could just manually create byte stream and write to it just as I reached so far I could make this project even better, since its so close to what I need exactly. Is there any instruction how to run this C+js code for dev? |
Ah I was proposing new behaviors, not describing the current behavior, sorry.
Sourceforge is down right now, but that's a libpng function that I think is documented here: http://www.libpng.org/pub/png/pngdocs.html
To build it from source? You need to install the dependencies (see https://github.com/Automattic/node-canvas/wiki), and then you can build it with |
Ok thanks, so I will try to prepare PR on the weekend. As I see all we need is to conditionally run some png_set_* functions. It seems to be PNG12 library and let to specify palette dividable by 3 as well with ignoring of transparency allocation and invocation of png_set_tRNS. |
I have created PR. #1629 Added control over tRNS. I need good review. I have noticed if you pass an index ouf of palette defined indexes it will not generate bKGD. I tried to make use of Also there is tricky code that makes We can switch discussion to PR and close this one. |
Hello,
I have created png using canvas.createPNGStream(). Passed palette for indexed png. As a result I get chunks: IHDR, PLTE, tRNS, bKGD, IDAT. I dont want tRNS and bKGD, but instead I would like to set pHYs. How can I control over what chunks will be generated?
The text was updated successfully, but these errors were encountered: