Bug 492236

Summary: Flattened image won't export to Photoshop (Colorspace differences)
Product: [Applications] krita Reporter: ken jacobsen <ken>
Component: Brush enginesAssignee: Halla Rempt <halla>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73, ghevan, halla, penguinflyer2222
Priority: NOR    
Version: 5.2.1   
Target Milestone: ---   
Platform: macOS (DMG)   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: The file that won't export to Photoshop

Description ken jacobsen 2024-08-26 21:38:52 UTC
Created attachment 172988 [details]
The file that won't export to Photoshop

***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY
Other similar images will export to Photoshop but this one won't for some reason , whether the colorspace is "gray built-in" or "Grayscale/Alpha Dot Gain 20%"


STEPS TO REPRODUCE
1. File/Export
2. Photoshop image
3. Save

OBSERVED RESULT
'Error: cannot save this image as a Photoshop image... one or more layers with a color model that is different from the image."

EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 vanyossi 2024-08-26 22:45:08 UTC
I can confirm the bug in master with the file provided. I have not look deep enough yet, but manipulating the image and layers from the GUI does not fix the issue.
Comment 2 Freya Lupen 2024-08-26 22:51:23 UTC
There is a hidden layer in the file called "decorations-wrapper-layer" with a color profile of sRGB-elle-V2-srgbtrc.icc, which is caused by "Show Guides" being on. Turning off "Show Guides" lets the file export as PSD.
Comment 3 Halla Rempt 2024-08-27 07:48:10 UTC
Something like

diff --git a/libs/impex/ColorModelHomogenousCheck.h b/libs/impex/ColorModelHomogenousCheck.h
index 494791e538..7bdf576c1c 100644
--- a/libs/impex/ColorModelHomogenousCheck.h
+++ b/libs/impex/ColorModelHomogenousCheck.h
@@ -84,7 +84,7 @@ private:
     bool check(KisNode * node)
     {
         KisLayer *layer = dynamic_cast<KisLayer*>(node);
-        if (layer) {
+        if (layer && layer->name() != "decorations-wrapper-layer") {
 
             const KoColorSpace * cs = layer->colorSpace();
             if (cs->colorModelId() != m_colorModelID || cs->colorDepthId() != m_colorDepthID) {

Should prevent this warning from happening, but I wonder how many other layer visitors need the same thing.
Comment 4 Dmitry Kazakov 2024-08-27 08:22:18 UTC
Hi, Halla!

You should use `KisBaseNode::isFakeNode()` for skipping non-exportable nodes.
Comment 5 Halla Rempt 2024-08-27 08:55:39 UTC
Right! Will do.
Comment 6 Halla Rempt 2024-08-27 08:59:03 UTC
Git commit 02671ca7e0b77c2dc5d90f4b237f28b470557a72 by Halla Rempt.
Committed on 27/08/2024 at 08:57.
Pushed by rempt into branch 'krita/5.2'.

Check whether a layer is fake

The homogenous check should disregard fake nodes.

M  +1    -1    libs/impex/ColorModelHomogenousCheck.h

https://invent.kde.org/graphics/krita/-/commit/02671ca7e0b77c2dc5d90f4b237f28b470557a72
Comment 7 Halla Rempt 2024-08-31 10:56:58 UTC
Git commit 28a8d2d4d5a67c6e398511a7501bd1b8afc42b23 by Halla Rempt.
Committed on 31/08/2024 at 10:56.
Pushed by rempt into branch 'master'.

Check whether a layer is fake

The homogenous check should disregard fake nodes.
(cherry picked from commit 02671ca7e0b77c2dc5d90f4b237f28b470557a72)

M  +1    -1    libs/impex/ColorModelHomogenousCheck.h

https://invent.kde.org/graphics/krita/-/commit/28a8d2d4d5a67c6e398511a7501bd1b8afc42b23