On Mon, Jan 28, 2013 at 4:46 AM, Philipp Schumann
<
philipp....@gmail.com> wrote:
> Go's image package provides the image/color.Model type for a number of color
> models (rgba, nrgba, grayscale, luminance/alpha) but I'm wondering how to
> figure out, upon Decode()ing a jpg or png (or other arbitrary image.Image),
> if that image was originally encoded in linear space or gamma space (sRGB).
>
> Or are all images automagically converted to linear or non-linear color
> space? Probably not.
There is no automatic conversion, and the Go 1.0 image.RGBA and
color.RGBA types do not hold gamma information.
If I were you, I would fork e.g. the image/png package and change it
to additionally return color space information
(
http://www.w3.org/TR/PNG/#11addnlcolinfo describes the cHRM, gAMA,
iCCP, sBIT, and sRGB chunks). If forking image/jpeg, you will probably
need to look in the EXIF metadata:
http://www.exiv2.org/tags.html
lists a number of fields mentioning "color space" or "gamma", but I
don't know the details, or the gamma-aware way to convert YCbCr to
RGB.