Replace linear Rec2020 Output Profile with sRGB for web gallery

I have used DarkTable for several years to process raw bird photography images. I export the processed images to Digikam as JPGs for tagging with species information, and then to produce web galleries for display.

This is for personal usage, and even my best is nowhere near professional quality. In fact the photos range from rubbish (poor light slightly off focus) to acceptable - sharp, well lit, bird well posed.

I just got back from a bird photo trip to Chiapas and Oaxaca in Mexico, with around 1500 photos, which I processed with DT 3.0.0 learning a lot about filmic_rgb and linear colour spaces on the way. (great work from the whole team, and great explanations from Aurelien himself!)

Anyway, I read about linear Rec2020 being the right profile to use, and changed all the settings accordingly. In fact I changed the Output Profile too, so when I exported the photos to Digikam, all the JPGs had an embedded linear Rec2020 .icc profile. No problem for Digikam on my desktop screen, and I happily identified and tagged over 1,000 photos with bird names.

The trouble came when creating a web gallery. I use the Pix package because it gives me an easy way to auto-add my Digikam tags as text under each photo so that people know what bird they are looking at on the web page. Pix does not read the .icc file, and I am guessing it does a crude conversion to sRGB, so the photos are significantly darker and lower quality on the screen.

If I re-export the photos from Darktable using the sRGB Output profile then all is well and the Pix produced web gallery looks OK. However, I would have to find a way to copy tags across to the new jpgs which could be a lot of work, as I had to do a bit of renumbering the files.

I tried to use exiftool to strip the .icc profiles from jpgs and reattach an .icc extracted from a good photo exported from Darktable using sRGB profile, but this doesnt work as Digikam and Pix don’t seem to recognise the attached .icc

I’m not an expert so I may be wrong about the cause of the problem - anyone got any thoughts or suggestions?

Not familiar with Pix, but if it’s not using the embedded profile, whatever it is, to convert the image to the display profile (what’s referred to as “color-managed”), then Pix is probably just pushing the Rec2020 pixels to the screen as-is.

The thing to realize about embedded icc profiles is that they (should) represent how the image is encoded, both tone- and color-wise. When a color-managed picture viewer goes to display an image, it takes the embedded profile and uses it as the starting information to convert the image to the display profile. That profile information is to the image color and tone what the width and height numbers are to its dimensions - critical to interpreteting the image data.

Rec2020 is a good working profile, but you should not exports JPEGs for display with it. Darktable lets you specify an output profile; for display that really should be sRGB, at least until the predominant displays out in the wild become some manifestation of wider color gamut, sometime after the year 2100… :grin:

2 Likes

It’s advised to use sRGB for web purposes.
You will have to reexport from darktable, or convert them.

Yes but the problem I am having is to convert the JPGs.
Removing the embedded .icc file and attaching an .icc for sRBG using exiftool doesnt seem to work.
Maybe I am misunderstanding something, but just looking for suggestions on how to do it.

What I did was to export an image from Darktable using the sRGB (web-safe) profile and perceptual intent. I then extracted the profile using:
exiftool -icc_profile -b -w icc Goodimage.jpg

renamed the resulting profile to sRGB.icc

and attached this to the target image with

exiftool “-icc_profile<=sRGB.icc” Badimage.jpg

For some reason this process does not result in an image that displays well in Pix, or in fact in Gwenview or Digikam, which makes me think I am misunderstanding something.

What is the encoding (the embedded profile) of Badimage.jpg? If it isn’t sRGB, then assigning a sRGB profile won’t help. Instead, you need to convert from the embedded profile to the sRGB profile. exiftool can’t do that. ImageMagick can:

magick Badimage.jpg -profile sRGB.icc Badimage.jpg

The will re-encode all pixels from whatever the embedded profile is, to sRGB.icc, and embed that profile, and overwrite the file.

1 Like

I’d like to see that profile…

Alan nails it here. Thing is, when you exported from darktable with sRGB, darktable should be doing the conversion. Now, perceptual intent might be your problem; try relative_colorimetric instead…

OK I see my error. I was assuming that the .icc file was a reference file indicating how the jpg should be interpreted. I didnt realise that Darktable was modifying every pixel during the export process.

Badimage profile was created by Darktable using “linear Rec2020” and looks like this:
Profile CMM Type : Unknown (lcms)
Profile Version : 2.1.0
Profile Class : Display Device Profile
Color Space Data : RGB
Profile Connection Space : XYZ
Profile Date Time : 2020:01:27 12:45:27
Profile File Signature : acsp
Primary Platform : Apple Computer Inc.
CMM Flags : Embedded, Independent
Device Manufacturer :
Device Model :
Device Attributes : Reflective, Glossy, Positive, Color
Rendering Intent : Perceptual
Connection Space Illuminant : 0.9642 1 0.82491
Profile Creator : Unknown (lcms)
Profile ID : 0
Profile Description : Linear Rec2020 RGB
Profile Copyright : Public Domain
Media White Point : 0.3127 0.32899 1
Chromatic Adaptation : 1.04788 0.02292 -0.05022 0.02959 0.99048 -0.01707 -0.00925 0.01508 0.75168
Red Matrix Column : 0.67348 0.27904 -0.00194
Blue Matrix Column : 0.12505 0.04561 0.79684
Green Matrix Column : 0.16566 0.67534 0.02998
Red Tone Reproduction Curve : (Binary data 14 bytes, use -b option to extract)
Green Tone Reproduction Curve : (Binary data 14 bytes, use -b option to extract)
Blue Tone Reproduction Curve : (Binary data 14 bytes, use -b option to extract)
Chromaticity Channels : 3
Chromaticity Colorant : Unknown (0)
Chromaticity Channel 1 : 0.70799 0.29201
Chromaticity Channel 2 : 0.17 0.797
Chromaticity Channel 3 : 0.131 0.04601
Media Black Point : 0 0 0
Device Model Desc : Linear Rec2020 RGB
Device Mfg Desc : Darktable

I’ll try the magick conversion on a new export using relative_colorimetric

1 Like

In ImageMagick, you can use “-intent”, like this:

magick Badimage.jpg -intent Relative -profile sRGB.icc Badimage.jpg

See ImageMagick - Command-line Options

Be aware that not all profiles support all intents. If your request is not supported, IM (or the LCMS library) will silently fallback to another one.

1 Like

All worked great - many thanks to everyone!

2 Likes

Using image magick to convert the colourspace in the jpeg is not a good idea – better to reexport the images from darktable, but this time choosing an output profile of sRGB. The Linear Rec 2020 RGB profile is used as your colour space in the input profile, where the camera raw is converted into a wide gamut colourspace suitable for an internal representation for doing your editing. You only go to the narrow gamut sRGB colourspace at the final stage where you export the image.

2 Likes

As a general rule: never use JPG as an input format to ImageMagick (or any other tool) unless you have no choice. This is because JPG is generally lossy, and repeated reading/writing JPG will lose more.

So, if we use darktable to save an image and then use ImageMagick to change the profile, we should use a lossless format for the intermediate file.

Ideally, we wouldn’t need to make a sRGB version because all downstream software would read the embedded profile and convert to sRGB if needed.

But the world isn’t ideal. We need to make sRGB versions. As @Matt_Maguire suggests, these should be regarded as output-only files, not as sources for future editing.

1 Like

It is, but if you change way how values from jpg file should be interpreted, you have to change also those values, to show same color.
E.g. 8bit [0-255] value in wider color space like rec2020 describe something very different than same value in sRGB.