-
Notifications
You must be signed in to change notification settings - Fork 125
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
An API to compress raw image data? #376
Comments
Would something like https://github.com/ShyykoSerhiy/canvas-png-compression help in the interim by allowing a level-0/1 compressed PNG as the input? |
@TPS IIUC, that's completely different codec, so no. |
Sure, but you're aiming to (1) speedup the process & (2) skip compressing the PNG 2×, right? The 2nd part would involve implementing this RFE, but the 1st could be kludged by something like that, since a level 0 or 1 compression is very fast, & then real recompression could be done by OxiPNG. Else, you're using the browser's PNG API, which is unnecessarily compressing the PNG, when all you need is the format to send to OxiPNG. |
@TPS I see what you're saying. But the real goal here is not as much / not only to speed up the process, but to reduce amount of code loaded in the browser. Speed-wise this initial compression via browser's API and decompression by OxiPNG is already a relatively fast part of the overall encoding compared to all the combinations that OxiPNG attempts, while size-wise adding one more dependency means only increasing the size even further. |
This may be worth adding. I don't think it would overly complicate the API and should be reasonably straightforward to implement, as the new method could pass along the image data to the existing internals. Clearly I haven't had the greatest amount of free time, but I would accept a PR for this (or I'll get around to adding it eventually). |
FWIW it's not a high priority on my list either, just something that seems worthwhile adding at some point in the future. (which is another way of saying I'm not sure I'll get around to a PR very soon either :) ) |
Is this issue/request about passing raw byte data and having it encoded with oxipng? I am looking for the first and trying to hack my way through it, |
I've been thinking about what such an API might look like. I figure if we use the existing PngImage struct it might look like this:
We might want to make some changes to these structs to make them more appropriate here:
What do you think @RReverser @Zerowalker? Would this work for your use cases? |
Sorry, it's been a while and I no longer work on the project where it was relevant :( TL;DR that was for squoosh.app, where we pass images from canvas ImageData (aka raw RGBA byte array) to various image codecs, but I can't dig in to verify API details at this point anymore. |
@RReverser Is it possible for you to tag who currently might be interested over @ Squoosh? 🙇🏾♂️ (Maybe @surma &/or @jakearchibald, but I'm not sure.) |
Hey all, I've just posted a draft PR #482. I want to make sure it's an appropriate solution that will work for whatever use case you may have, so please check it out and post any feedback you have. |
I'm still interested in this, but it isn't urgent for us, since we can encode it to PNG before passing it to Oxi. |
Now that #482 (& a bevy of other performant PRs) has landed, what do you think, @jakearchibald? |
@jakearchibald is out of Google now too 😅 If you want to implement this in a PR, I'm sure one of us will be happy to review it though! |
Right now, in Squoosh, OxiPNG is the only codec where we need to encode the raw image data we already have (RGBA) into PNG with browser API, only to pass to OxiPNG, which will decompress it back.
I wonder if there could be a way to expose an API that would accept raw RGBA byte array and try to compress that directly. This could make it both faster and smaller by excluding the decoder from the process.
The text was updated successfully, but these errors were encountered: