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

Streaming image decoding via go channels #50

Open
gmp216 opened this issue May 16, 2018 · 0 comments
Open

Streaming image decoding via go channels #50

gmp216 opened this issue May 16, 2018 · 0 comments

Comments

@gmp216
Copy link

gmp216 commented May 16, 2018

For interactive programs, it is useful to be able to decode large images in pieces in order to improve responsiveness. I have implemented a draft version of a "streaming" API which returns Subimages on a go channel if a channel is passed to the jpeg.Decode function. See here:

https://github.com/gmp216/go-libjpeg/tree/streaming

If no channel is provided, the Decode function should perform as before. This is useful but not fully implemented yet since rgb.Image does not implement the Subimage function that is available for most of the built-in image types (DecodeRGB and DecodeIntoRGB return Subimages with the wrong bounds).

Example:

fd,err := os.Open(filename)
ch := make(chan image.Image)
go func() {
    for im := range(ch) {
        ...
    }
}()
i,err := jpeg.Decode(fd,&jpeg.DecoderOptions{},ch)
...

Any thoughts on this implementation are appreciated. Currently it is not possible to specify the number of lines (or max pixels) to return in each Subimage. This could possibly be added as an option in jpeg.DecoderOptions.

@harukasan harukasan mentioned this issue Aug 21, 2019
3 tasks
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

1 participant