Skip to content

Streaming image decoding via go channels #50

Open
@gmp216

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions