image-rs / image

Encoding and decoding images in Rust
Apache License 2.0
4.88k stars 605 forks source link

Streaming Image encoders #1219

Open lovasoa opened 4 years ago

lovasoa commented 4 years ago

I would like to be able to encode images that do not fit in memory.

My specific use case for this functionality is dezoomify-rs, which handles very large images directly on users' machines with limited memory.

This is more generally applicable to any application handling large images.

Draft

Several image encoders do already provide a streaming encoder:

Some others do not, but have a structure that simply iterates on an image's pixels which should make it easy to implement, such as

It would be awesome if image-rs could provide a simple interface that would abstract away each individual codec implementation and provide a generic streaming image encoder. The encoder would be created by specifying the image size, then would have a method allowing to add pixels to it. The pixels would be optionally buffered based on the underlying image codec's chunk size requirements, then provided to it.

birktj commented 3 years ago

See also #867