Bug 333322 - PSD: rootLayer wrongly mixed with alpha
Summary: PSD: rootLayer wrongly mixed with alpha
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: unspecified
Platform: unspecified Unspecified
: NOR normal
Target Milestone: ---
Assignee: Halla Rempt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-11 14:29 UTC by Dalai Felinto
Modified: 2015-05-27 12:48 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
kra test file saved as psd with 310c38a9e1bc3e3bc8349ce5d6dfecf0375f6d7e (146.55 KB, image/vnd.adobe.photoshop)
2015-05-27 07:19 UTC, Halla Rempt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dalai Felinto 2014-04-11 14:29:00 UTC
The composed layer (aka rootLayer, aka flattened down version of the image saved for maximum compatibility) in Photoshop is supposed to be mixed with the background and alpha.

When the PSD file doesn't store the background, the background value to consider is 1.0 (0xFF actually). 

The formula should be as follow:
CompRGB = RGB + (1 - Alpha) * Background
RGB = CompRGB - (1 - Alpha) * Background

Example/test file:
-----------------------
* grid-native.psd:
https://developer.blender.org/file/info/PHID-FILE-ke5zv6lseynjjh7gktcg/
[original file, created and saved in Photoshop]

* grid-krita.psd:
https://developer.blender.org/file/info/PHID-FILE-o5piv6rqpgego4hy7763/
[grid-native-psd file opened in krita and re-saved as Photoshop]

* reference:
http://wiki.blender.org/index.php/File:Dev-PhotoshopAlphaGrid.png
[the grid scaled up and other extra info]

Raw data comparison:
https://developer.blender.org/P36

Related info:
* https://developer.blender.org/T39652
* https://github.com/OpenImageIO/oiio/commit/342cc2633ff590a3bb278481c61ae798c7148361
* http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577411_31265


Reproducible: Always
Comment 1 Paul Geraskin 2014-04-11 14:52:06 UTC
Yes! 

This breaks blender. :( 
https://developer.blender.org/T39652
Comment 2 Halla Rempt 2014-04-28 14:11:54 UTC
Yes, I can confirm. Sorry for the delay, I was too busy with other parts of krita and then I had to take a bit of a break.
Comment 3 Halla Rempt 2014-08-23 09:58:09 UTC
Git commit 63ccd2f2ec09778e4f11bdef5c6323bef22377ff by Boudewijn Rempt.
Committed on 23/08/2014 at 09:56.
Pushed by rempt into branch 'master'.

PSD: fix saving the composed image

The composed image data in Photoshop should be pre-filled with white.
Related: bug 333300

M  +15   -1    krita/plugins/formats/psd/psd_image_data.cpp
M  +1    -1    krita/plugins/formats/psd/psd_image_data.h

http://commits.kde.org/calligra/63ccd2f2ec09778e4f11bdef5c6323bef22377ff
Comment 4 Paul Geraskin 2014-08-23 19:44:49 UTC
I'll test your changes at monday too. This is different issue.
Comment 5 Halla Rempt 2014-09-26 08:54:14 UTC
Git commit 8f4f989086576c2ab30de20b128764b366ffd2ff by Boudewijn Rempt.
Committed on 23/08/2014 at 09:56.
Pushed by rempt into branch 'calligra/2.8'.

PSD: fix saving the composed image

The composed image data in Photoshop should be pre-filled with white.
Related: bug 333300

M  +15   -1    krita/plugins/formats/psd/psd_image_data.cpp
M  +1    -1    krita/plugins/formats/psd/psd_image_data.h

http://commits.kde.org/calligra/8f4f989086576c2ab30de20b128764b366ffd2ff
Comment 6 Paul Geraskin 2014-09-26 09:18:49 UTC
Hello.
I updated Master branch. Still not fixed http://i.imgur.com/SlwiNx6.png
Comment 7 Dalai Felinto 2014-09-27 12:07:26 UTC
Paul the problem can always be in the Blender end. Can you share the generated PSD file?
(or even better, a simpler PSD file similar to the 5x5 grid file I was using for tests? - see here - http://wiki.blender.org/index.php/User:Dfelinto/Foundation#Week_2_.28September_23th.29 )
Comment 8 Paul Geraskin 2014-09-27 12:20:26 UTC
Take it https://dl.dropboxusercontent.com/u/26887202/Krita/test_psd_alpha.zip
I added krta file and generated psd file.
Comment 9 Paul Geraskin 2014-09-27 12:21:33 UTC
also take a note - image viewres on linux and fimp open this psd ok. Only blender and mac apps have this issue.
Comment 10 Halla Rempt 2015-05-26 18:07:56 UTC
Okay, I tested Paul's test image: this now looks exactly the same in Krita and Photoshop. Is there anything else needed?
Comment 11 Dalai Felinto 2015-05-26 18:39:36 UTC
(In reply to Boudewijn Rempt from comment #10)
> Okay, I tested Paul's test image: this now looks exactly the same in Krita
> and Photoshop. Is there anything else needed?

Can you share the .psd generated on the latest Krita from Paul's krita file so I can test on Blender too?
Comment 12 Halla Rempt 2015-05-27 07:19:47 UTC
Created attachment 92843 [details]
kra test file saved as psd with 310c38a9e1bc3e3bc8349ce5d6dfecf0375f6d7e

Sure! Here it is.
Comment 13 Paul Geraskin 2015-05-27 08:19:14 UTC
Here is the result of the PSD in Blender and Gwenview.
http://i.imgur.com/4NZcl12.png
Comment 14 Halla Rempt 2015-05-27 08:29:08 UTC
Hum, if krita, gwenview, photoshop and gimp all display the file the same way, and blender does it differently, I'm inclined to conclude the bug is blender's...
Comment 15 Dalai Felinto 2015-05-27 11:39:12 UTC
The remaining issue seems to be related to the embed colorspace:
This is what I get in Blender when loading the above file:

"imb_load_photoshop: The embed colorspace ("") not supported in existent OCIO configuration file. Fallback to system default colorspace ("sRGB")."

But this is already reported here:
https://bugs.kde.org/show_bug.cgi?id=334582
Comment 16 Halla Rempt 2015-05-27 12:30:33 UTC
Closing this bug then.
Comment 17 Paul Geraskin 2015-05-27 12:40:40 UTC
Wait guys. Are you sure this is ICC?
I converted ti Builin ICC and i gor the same issue.
http://i.imgur.com/hFWLMUR.png

Here is my attachment of the buildin icc. https://bugs.kde.org/attachment.cgi?id=92850
Comment 18 Halla Rempt 2015-05-27 12:48:33 UTC
rRGB built-in is one of the LCMS-generated ICC profiles; the one I tested with is one created by Elle Stone. Photshop CS2 loads both images and shows the correct ICC profile in the statusbar.

I don't know what the issue in Blender is, and it might be that we don't save the ICC profile in a secondary or tertiary way Photoshop can store ICC profiles, of course