Skip to content
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

Chunked output #20

Open
LinusU opened this issue Oct 20, 2015 · 1 comment
Open

Chunked output #20

LinusU opened this issue Oct 20, 2015 · 1 comment

Comments

@LinusU
Copy link

LinusU commented Oct 20, 2015

Would it be possible to add a streaming api where you load the source data in (my understanding of png compression is that you need the whole image do the compression) and then get chunks of data back.

Somehow incrementally calling a function that returns a bit more of the output, and at last returns that it's done.

Would this be feasible or am I overlooking something in how png works that would make this bad?

@lvandeve
Copy link
Owner

Hi,

The PNG file format itself supports this (see *), but the LodePNG encoder and decoder don't support streaming, LodePNG requires full data available. Adding support for this will require a drastic code change, so is not likely to happen soon.

If a streaming API is required, then probably the official libpng library (http://www.libpng.org/pub/png/libpng.html) will be more suitable.

(*) The PNG file format supports streaming, because PNG filters on pixels depend only on past pixels. The deflate compression used also only depends on past data, it just requires working on blocks of data at a time. PNG supports interlacing, which is designed to load the PNG in a streaming fashion, from low resolution to higher, which is done in web browsers. LodePNG can read those, but all at once, no streaming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants