Emit multiple data chunks from output Streams (was: Proper streaming)
See original GitHub issueIt would be very cool if sharp
could support proper streaming. As it is now, it will always emit exactly one data
event which is the whole image. It kind of defeats the purposes of streams.
As I see it there is two ways to implement this.
-
The hard, but robust way.
Every time that
libvips
have data that should be written, it should call a function that we have defined. We then use this data to generate adata
-event on the stream. It would be really cool iflibvips
could provide a state-machine that has a synchronous function that gives the next chunk. That waypause
andunpause
would work perfectly. -
The quick and easy fix.
We can also create a named pipe and tell
libvips
to write it to that file viavips_image_write_to_file
. To the user we would then return aReadStream
as returned byfs.createReadStream(path)
.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:4
- Comments:16 (4 by maintainers)
@jcupitt great work on the streams branch, a shame it could never be merged. Just adding my support for any work on true streams, which would allow significantly less memory usage since right now sharp needs to load the source image into memory, and then hold the whole output buffer in memory, before writing out.
@lovell is this still on the roadmap given
sharp
is now using libvips 8.9?