guardian / grid

The Guardian’s image management system
https://www.theguardian.com/info/developer-blog/2015/aug/12/open-sourcing-grid-image-service
Apache License 2.0
1.44k stars 121 forks source link

Colour wrong for images only tagged via DCF EXIF #2066

Open paperboyo opened 7 years ago

paperboyo commented 7 years ago

Hello,

This affects all frontend display of images sent straight from cameras that are set to record AdobeRGB, e.g. images from Tom Jenkins

grid-dcf-exif-bug

Camera makers often do not actually embed ICC profiles in camera JPEG images (I’ve tested two from Canon and Nikon). Instead they use DCF EXIF tags to specify sRGB or AdobeRGB (pt. A2). Grid does not recognise this and treats these images as untagged. That is no problem for sRGB images as they are assumed to be sRGB anyway, but colour saturation/tonality suffers for images tagged as AdobeRGB. This affects both Grid’s thumbnails and all exports (including a master asset!).

For all JPEG images of an RGB colour model that do not explicitly have embedded ICC profiles, we should read both 0xa001 ColorSpace and 0x0001 InteropIndex EXIF tags and explicitly embed AdobeRGB before performing any image operations when 0x0001 InteropIndex = 'R03' = R03 - DCF option file (Adobe RGB) and 0xa001 ColorSpace = 0x2 = Adobe RGB (this pertains only to untagged images; when there is a ICC profile present, it should always take precedence even if the above tags are set)

GraphicsMagick does not identify 0x0001 InteropIndex, so unless we are willing to contribute and update it, we can look into using exiftool to do it. Or maybe metadata-extractor itself (we would most probably need to import additional EXIF directory (?)).

Regards Mateusz

paperboyo commented 6 years ago

Yeah, so take affected 45c71141a66d7dcc61fd0e09eb90d8c1c1d091b2.

Read that there is no embedded ICC profile: fileMetadata:xmp:icc{}

Then read fileMetadata:exifSub:Color Space:"Undefined" and don’t worry, it means AdobeRGB then read something we do not currently read (?) https://github.com/drewnoakes/metadata-extractor/blob/master/Source/com/drew/metadata/exif/ExifDirectoryBase.java#L618 [EDITED] then apply AdobeRGB profile.

And enjoy correct colour (left): image