Skip to content

proposal: image/jpeg: support color channels other than 8 bits, eg Gray16 #51904

@DanielHeath

Description

@DanielHeath

Go version: All recent, including 1.18.
OS: Linux / AMD64

In (e.g) image/jpeg/writer.go:620 , the encoder switches on the underlying image type (case *image.Gray:).

However, it has no check for color.Grey16, leading to that format being encoded incorrectly (the least significant 8 bits are discarded silently).

While many viewers elect not to implement it, the jpeg format supports wider color channels than 8 bit.

Specifying the number of color components and their size in the encoder options would allow the implementation to be used for e.g. medical imaging & scientific instrument data.

I propose that when the size or number of components is set to 0, the existing detection code is used instead (no change when not using the new options), unless you are encoding an image in the Grey16 color space.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions