Bug 376836 - Reading and writing mask to PSD with color profile above 8bit is broken
Summary: Reading and writing mask to PSD with color profile above 8bit is broken
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: 3.1.2
Platform: Other All
: NOR major
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-23 09:40 UTC by Alex
Modified: 2017-04-27 08:29 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
psd with layer mask (339.27 KB, application/octet-stream)
2017-02-23 11:10 UTC, Alex
Details
psd saved form krita with mask (15.68 KB, image/vnd.adobe.photoshop)
2017-02-27 16:45 UTC, Raghavendra kamath
Details
mask_test_2017 (33.43 KB, image/vnd.adobe.photoshop)
2017-02-27 18:27 UTC, Alex
Details
mask_krita_2017 (31.63 KB, image/vnd.adobe.photoshop)
2017-02-27 18:27 UTC, Alex
Details
mask_krita_screen0001 (33.40 KB, image/jpeg)
2017-02-27 18:28 UTC, Alex
Details
mask psd created with photoshop cs3 (45.25 KB, image/vnd.adobe.photoshop)
2017-02-28 04:10 UTC, Raghavendra kamath
Details
mask psd created with photoshop cs3 (57.21 KB, image/vnd.adobe.photoshop)
2017-02-28 04:11 UTC, Raghavendra kamath
Details
mask psd created with photoshop cs3 (56.84 KB, image/vnd.adobe.photoshop)
2017-02-28 04:11 UTC, Raghavendra kamath
Details
Same file as first one but with 8bit color depth. (35.20 KB, image/vnd.adobe.photoshop)
2017-02-28 07:38 UTC, Alex
Details
Same file as first one but with 32bit color depth. (658.67 KB, image/vnd.adobe.photoshop)
2017-02-28 07:39 UTC, Alex
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex 2017-02-23 09:40:20 UTC
I'm not sure if it's bug or missing feature, but as title states: when opening PSD containing layer mask Krita reads and assigns psd layer mask to own transparency mask, but mask is empty, all white. I can provide simple psd to test.
Comment 1 Halla Rempt 2017-02-23 10:38:48 UTC
Sounds like a bug -- I haven't tested whether I can reproduce yet, but yes, please attach a simple test file.
Comment 2 Alex 2017-02-23 11:10:20 UTC
Created attachment 104186 [details]
psd with layer mask
Comment 3 Halla Rempt 2017-02-27 13:48:32 UTC
I can confirm that we load an empty mask, and that saving a mask from krita to psd also fails now. No mask seems to be saved.
Comment 4 Raghavendra kamath 2017-02-27 16:44:48 UTC
@Alex can you also post a screenshot of the actual mask just to get an idea what it looks like. I have some of my old psds and they load a layer mask as transparency mask too but they are not empty. These masks were created in photoshop cc early 2014 version. 

Can you also state which version of photoshop is used to create these mask, we never know there might be some changes how photoshop saves them now. 

I am also attaching a psd created from krita (3.1 git version) it has a transparency mask on the top layer. can you please check if it is okay. it loads correctly in krita
Comment 5 Raghavendra kamath 2017-02-27 16:45:16 UTC
Created attachment 104244 [details]
psd saved form krita with mask
Comment 6 Alex 2017-02-27 18:27:29 UTC
Created attachment 104247 [details]
mask_test_2017
Comment 7 Alex 2017-02-27 18:27:49 UTC
Created attachment 104248 [details]
mask_krita_2017
Comment 8 Alex 2017-02-27 18:28:37 UTC
Created attachment 104249 [details]
mask_krita_screen0001
Comment 9 Alex 2017-02-27 18:30:50 UTC
My mask was saved with 2014 version (I'm just used to it). I've attached both files saved with 2017. Screen from 2014, files opened saved by 2017.
Comment 10 Raghavendra kamath 2017-02-28 03:28:04 UTC
So the mask that I created from Krita is loading correctly in photoshop, boud also tested my masks in photoshop cs2 they work correctly, so krita saves masks correctly in psd


Thank you for the screenshot, your mask loads correctly in photoshop cs2 for boud, but not in krita both of ushave tested that. May be there is a problem with masks created with recent version of photoshop. Do you have any other files possibly created with older version of photoshop (untouched or not resaved in latest version) that load correctly in krita , do all psd  files load empty masks in krita for you?

Sorry for asking such repetitive question, I am just trying to determine which version of photoshop created emtpy transparency masks in krita, because i have some files created in photoshop cc 2014 that load correctly in krita.
Comment 11 Raghavendra kamath 2017-02-28 04:08:29 UTC
With the help of a friend I managed to get various psd with mask (both single layer and two layered, inversed and non inversed mask) . these psd were created in  photoshop cs3 . And they load as intended in krita for me. attaching those psd here
Comment 12 Raghavendra kamath 2017-02-28 04:10:30 UTC
Created attachment 104255 [details]
mask psd created with photoshop cs3

this psd which has mask created with photoshop cs3 loads correctly in krita
Comment 13 Raghavendra kamath 2017-02-28 04:11:07 UTC
Created attachment 104256 [details]
mask psd created with photoshop cs3

This psd also loads correctly created in photoshop cs3
Comment 14 Raghavendra kamath 2017-02-28 04:11:42 UTC
Created attachment 104257 [details]
mask psd created with photoshop cs3
Comment 15 Alex 2017-02-28 07:36:56 UTC
I think I know what's wrong. My file is 16bit per channel, Krita seems to read 8 bit correctly but not 16 bit. Also when trying to convert my image to 16bit in Krita there is error message that it can't save image with different layer depth. Take a look @ attachment.
Comment 16 Alex 2017-02-28 07:38:43 UTC
Created attachment 104260 [details]
Same file as first one but with 8bit color depth.
Comment 17 Alex 2017-02-28 07:39:32 UTC
Created attachment 104261 [details]
Same file as first one but with 32bit color depth.
Comment 18 Raghavendra kamath 2017-02-28 07:42:31 UTC
@alex, good catch, I missed the fact that it is 16 bit psd. Also the 32 bit psd file you gave doesn't load in krita 3.1 it says internal error
Comment 19 Dmitry Kazakov 2017-04-21 14:07:05 UTC
I've found the reason of the issue. It uses ZIP compression for masks in newer version, which is not yet implemented. I'll check what we can do.
Comment 20 Dmitry Kazakov 2017-04-27 08:29:20 UTC
Git commit dcb9aab8cb9fb8868cc9f8d06c4533e1cecdb717 by Dmitry Kazakov.
Committed on 25/04/2017 at 16:01.
Pushed by dkazakov into branch 'kazakov/refactor-alpha-colorspaces'.

Implement reading of zipped layer transparency masks from PSD

Basically, we should an reuse already existing algorithm for
reading layer data.

Please note that we still don't support 32-bit PSD images.

Still TODO:
1) Check if we write the mask data correctly (that is using 16-bit)

M  +6    -40   plugins/impex/psd/psd_layer_record.cpp
M  +77   -8    plugins/impex/psd/psd_pixel_utils.cpp
M  +6    -0    plugins/impex/psd/psd_pixel_utils.h

https://commits.kde.org/krita/dcb9aab8cb9fb8868cc9f8d06c4533e1cecdb717
Comment 21 Dmitry Kazakov 2017-04-27 08:29:20 UTC
Git commit 989a4797359b0b7e743ecc5469cd3deff9631ce6 by Dmitry Kazakov.
Committed on 27/04/2017 at 08:27.
Pushed by dkazakov into branch 'kazakov/refactor-alpha-colorspaces'.

Fix writing of 16-bit transparency masks to a PSD file

M  +21   -4    plugins/impex/psd/psd_layer_record.cpp
M  +2    -0    plugins/impex/psd/psd_layer_record.h

https://commits.kde.org/krita/989a4797359b0b7e743ecc5469cd3deff9631ce6