Bug 408485

Summary: Colors appear darker when retrieving an external picture as a File Layer
Product: [Applications] krita Reporter: Tonja
Component: GeneralAssignee: Halla Rempt <halla>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73, ghevan, halla
Priority: NOR    
Version: 4.2.1   
Target Milestone: ---   
Platform: Appimage   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: A Zip archive containing the files needed for demonstrating the issue
Test files demonstrating the issue
Another test demonstrating the issue in a different way

Description Tonja 2019-06-09 16:11:53 UTC
Created attachment 120727 [details]
A Zip archive containing the files needed for demonstrating the issue

SUMMARY
Two common ways to get an external picture into a Krita project are importing it as a layer, or using a File Layer pointing to it.

Since at least version 4.2.1 (not present in 4.1.7 as shown in comparison.png), it seems that some wrong colorspace is applied to the picture when getting it in as a File Layer, resulting in overall darker colors. However, importing it as layer (Top bar menu > Layer > Import/export > Import as layer...) keeps the colors as they should be ( how_it_should_looks_like.jpg for reference). 

All of this happens in a Krita project (krita42Benchmarku.kra) using Linear scRGB colorspace, float16 precision , dual monitor setup (but changing the colorspace in Krita settings has no influence on solving the problem), Linux Parabola, using the official appimage. It doesn't seems to happen in a regular 8-bit sRGB project (using how_it_should_looks_like.jpg as a picture to import)

STEPS TO REPRODUCE
1. Extract example.zip archive : it should contain four files, krita42benchmarku.kra, external_picture_to_import.exr, comparison.png and how_it_should_looks_like.jpg
2. Open krita42benchmarku.kra with Krita-4.2.1. It has two layers, an imported layer and a File Layer
3. Use external_picture_to_import.exr as a target for the File Layer (and optionnally : reimport this file as layerwith Top bar menu > Layer > Import/export > Import as layer...)
4. See the flagrant difference between the File Layer and the imported layer
5. Try to do this with Krita-4.1.7 ; layers should look similar

OBSERVED RESULT
The File Layer looks darker than the imported layer in Krita 4.2.1, as shown in comparison.png (layer thumbnails are used for this comparison ; actual layers looks the same as their thumbnails)

EXPECTED RESULT
The File Layer should look similar to the imported layer and the same as how_it_should_looks_like.jpg, as in Krita 4.1.7

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Linux Parabola, LXDE, Thinkpad laptop (x230) with external screens
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: using the Appimage

ADDITIONAL INFORMATION
Comment 1 vanyossi 2019-06-11 03:46:40 UTC
Sorry I cant reproduce this on macOS

The kra file has 4 layers, and one file is missing.

"Sluthooves_BG.exr does not exist."

Deleting that layer as it does not seem important for the bug report, I tested using your steps, saved the image and reopne (to see if it was a refresh on newly opened files) but I could not get any difference between the layers.

Perhaps there is something icky in the color space settings. Does anything change if you set a different color space in "ColorSpace > Display"? Also if you untick the checkbox next to the colorspace options? (I don't recall the name as we disabled it from macOS and windows as it does nothing in those platforms)
Comment 2 Tonja 2019-06-11 22:35:28 UTC
Created attachment 120806 [details]
Test files demonstrating the issue

A better, proper benchmark for this bug report
Comment 3 Tonja 2019-06-11 22:42:11 UTC
(In reply to vanyossi from comment #1)
> Sorry I cant reproduce this on macOS
> 
> The kra file has 4 layers, and one file is missing.
> 
> "Sluthooves_BG.exr does not exist."
> 
> Deleting that layer as it does not seem important for the bug report, I
> tested using your steps, saved the image and reopne (to see if it was a
> refresh on newly opened files) but I could not get any difference between
> the layers.
> 
> Perhaps there is something icky in the color space settings. Does anything
> change if you set a different color space in "ColorSpace > Display"? Also if
> you untick the checkbox next to the colorspace options? (I don't recall the
> name as we disabled it from macOS and windows as it does nothing in those
> platforms)

Thanks for your answer. Sorry about the file, it seems like I linked some intermediate test file used to isolate the issue instead ; redid a clean archive with a better example. It will ask for locating external_picture_to_import.exr, which is also in the archive...

Using alternative color spaces sure changed the way the picture is displayed, but there was still a difference between the two layers. Checkbox is "Using monitor profile", it didn't had any influence on solving the issue either.
Comment 4 Bug Janitor Service 2019-06-12 04:33:09 UTC
Thanks for your comment!

Automatically switching the status of this bug to REPORTED so that the KDE team
knows that the bug is ready to get confirmed.

In the future you may also do this yourself when providing needed information.
Comment 5 Halla Rempt 2019-06-12 12:37:50 UTC
I can reproduce the issue, and I'll take a look.
Comment 6 Halla Rempt 2019-06-12 13:04:17 UTC
Um, I am not so sure anymore. I tried 3 versions of Krita:

3.3.3 loads external_picture_to_import.exr and shows it washed out, like the first layer of your test .kra file
4.1.7 and 4.2.1: loads it "darker", but there is no difference whether I load the exr directly, import it as a pixel layer or link to it as a file layer: it is always rendered the same way.

exrdisplay and imagemagick's display show the image like Krita 4.1.7 and 4.2.0 

How did you create the exr file?
Comment 7 Tonja 2019-06-12 18:45:18 UTC
Created attachment 120821 [details]
Another test demonstrating the issue in a different way
Comment 8 Tonja 2019-06-12 18:57:04 UTC
(In reply to Boudewijn Rempt from comment #6)
> Um, I am not so sure anymore. I tried 3 versions of Krita:
> 
> 3.3.3 loads external_picture_to_import.exr and shows it washed out, like the
> first layer of your test .kra file
> 4.1.7 and 4.2.1: loads it "darker", but there is no difference whether I
> load the exr directly, import it as a pixel layer or link to it as a file
> layer: it is always rendered the same way.
> 
> exrdisplay and imagemagick's display show the image like Krita 4.1.7 and
> 4.2.0 
> 
> How did you create the exr file?

It has been made with Krita, actually... With the last version or so there was early March. From a document created with 16 bits float depth and scRGB (linear) color space.

I did another test, this time involving only the two most recent versions of Krita : goal was to create another EXR picture with Krita 4.1.7,  then create a document with the exact same parameters under Krita 4.1.7 and Krita 4.2.1, and next importing as a layer and as a file layer, and see what happen with the colors. Files are in Benchmark2.zip.

1. I created a source document with options as described in krita_417_creation.png
2. Then I painted a bit on it, obtaining a reference look, and exporting it as a EXR file (shown in CreationUnderKrita417.png, Krita document is Krita417SourceDocument.kra, EXR export is Krita417GeneratedEXR.exr)
3. I created a new document under Krita 4.1.7 with the same parameters as the source (krita_417_creation.png), and imported (+ File Layer) Krita417GeneratedEXR.exr in it ; imported layer and File layer looks the same, but colors are slighly off compared to the reference for some reason (shown as EXRImportUnder417.png).
4. I then created a new document under Krita 4.2.1, did the import and File layer creation as in step 3 ; imported layer and File layer looked the same (differing for what happened with the old EXR file), but colors on both layers are strongly off, darker, compared to the reference (result in EXRImportUnder421.png)


By the way, the original issue also appears on Windows, had the opportunity to try on a completely different computer (Desktop, NVIDIA GPU, Intel i7 2xxx, Windows 10)
Comment 9 Tonja 2019-06-12 19:15:55 UTC
(In reply to Boudewijn Rempt from comment #6)
> Um, I am not so sure anymore. I tried 3 versions of Krita:
> 
> 3.3.3 loads external_picture_to_import.exr and shows it washed out, like the
> first layer of your test .kra file
> 4.1.7 and 4.2.1: loads it "darker", but there is no difference whether I
> load the exr directly, import it as a pixel layer or link to it as a file
> layer: it is always rendered the same way.
> 
> exrdisplay and imagemagick's display show the image like Krita 4.1.7 and
> 4.2.0 
> 
> How did you create the exr file?

There's even simpler, in fact : 
1. Create a document with Krita 4.2.1, floa1 16b, scRGB (Linear)
2. Paint a bit on it, export is as EXR
3. Import the then-created EXR file you just exported into the document you just made
4. Color appear darker and strongly different than in the original layer

But actually, Krita 4.1.7 does alterate the colors too... Only with a very slight difference, which could explain why I didn't noticed it in the first place.
Comment 10 Dmitry Kazakov 2019-06-13 13:04:52 UTC
I can confirm the issue. EXR files are loaded incorrectly, they use sRGB profile for some reason
Comment 11 Dmitry Kazakov 2019-06-13 13:13:51 UTC
The bug is a regression from 342b87f3a50947e0f90cb822c40b7e0dfc966cc2
Comment 12 Halla Rempt 2019-06-13 13:15:22 UTC
The default profiles for f16 and f32 should be linear gamma srgb, which should be correct...
Comment 13 Halla Rempt 2019-06-13 14:09:04 UTC
Git commit 89b58a7d124ac28c120ef9c958126338e833dbce by Boudewijn Rempt.
Committed on 13/06/2019 at 14:08.
Pushed by rempt into branch 'master'.

Use the right default profile for the current channel depth

defaultProfileForColorSpace needs a colorSpaceId including
the channelDepthId, not just the colorModelId.
BACKPORT:krita/4.2

M  +15   -10   plugins/impex/exr/exr_converter.cc

https://invent.kde.org/kde/krita/commit/89b58a7d124ac28c120ef9c958126338e833dbce
Comment 14 Halla Rempt 2019-06-17 08:18:07 UTC
Git commit 1b776e1bf839818c93192af1fe7321caa62373f2 by Boudewijn Rempt.
Committed on 17/06/2019 at 08:16.
Pushed by rempt into branch 'krita/4.2'.

Use the right default profile for the current channel depth

defaultProfileForColorSpace needs a colorSpaceId including
the channelDepthId, not just the colorModelId.
BACKPORT:krita/4.2

M  +15   -10   plugins/impex/exr/exr_converter.cc

https://invent.kde.org/kde/krita/commit/1b776e1bf839818c93192af1fe7321caa62373f2