Bug 430240 - Krita doesn't warn when exporting layers with multiple transparency masks into .psd
Summary: Krita doesn't warn when exporting layers with multiple transparency masks int...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Mint (Ubuntu based) Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-11 00:12 UTC by Tiar
Modified: 2021-04-16 13:21 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Test file (411.64 KB, application/zip)
2020-12-11 00:12 UTC, Tiar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tiar 2020-12-11 00:12:35 UTC
Created attachment 133984 [details]
Test file

SUMMARY
Photoshop doesn't support multiple transparency masks, so Krita silently discards them on saving to psd.


STEPS TO REPRODUCE
1. Open the test file.
2. Export into a .psd file.
3. Open the .psd file.

OBSERVED RESULT
No warning, but the masks are gone.

EXPECTED RESULT
Warning (or masks preserved).
Also maybe there is a way to save a merge of all of them? For example, discard all invisible ones and merge all visible ones so the result is the subset of all (merged with "AND" binary operation).


SOFTWARE/OS VERSIONS
Krita

 Version: 5.0.0-prealpha (git 6759a18)
 Languages: en_US, en, en_US, en, en_US, en, pl_PL, pl, pl_PL, pl
 Hidpi: true

Qt

  Version (compiled): 5.12.9
  Version (loaded): 5.12.9
Comment 1 Halla Rempt 2020-12-11 09:17:59 UTC
Think you can pick this up? It's a "simple" matter of just writing another capability check...
Comment 2 Srirupa Datta 2021-04-08 23:04:04 UTC
Can I work on this?

I was thinking that a warning dialog with two options can be shown, either to discard or convert into a single layer(as you suggested).

I also couldn't find how I can merge transparency masks like I can do with the paint layers. I was looking through the source code and found that the kis_mask source file doesn't have any merging function. Can this feature be added if it's not there? 

It might take some time as I'm not that familiar with the source code, but I'm willing to try!
Comment 3 Halla Rempt 2021-04-09 08:29:59 UTC
Yes, but you shouldn't show this in a separate dialog, but work within the existing file format capabilities framework. See libs/impex.
Comment 4 Srirupa Datta 2021-04-09 09:51:29 UTC
I was thinking about making something similar to what happens when I click, for example, the png option in the exporting dialog, and then on clicking Save, another dialog opens(PNG image - Krita), where I get options related to compression and all. So I was hoping to do something similar with psd, like I go to File -> Export -> Choose psd, and on clicking Save, a similar dialog opens(PSD - Krita), where on clicking Okay, the file gets saved.
Comment 5 Halla Rempt 2021-04-09 11:20:06 UTC
For the warning, you don't need to make any dialog. You need to make something similar to MultiLayerCheck that specifically checks for multiple transparency masks and integrate that in KisExportCheckRegistry. Then exporting a layer with multiple transparency masks to any file format that doesn't support those will give a warning automatically, together with all possible other warnings.

That's the first thing to do.

The second thing would be to change the psd export code to do the merging. We could add an export options dialog to PSD to give people a choice between merging and discarding, but... I am not convinced that we should do this. What we probably should do instead is save all further transparency masks as Photoshop channels, because that's the real equivalent of our transparency masks.
Comment 6 Srirupa Datta 2021-04-09 13:56:28 UTC
Oh, okay, got it.

I don't know much about Photoshop, but I thought that transparency mask in Krita is equivalent to layer mask in Photoshop, and channels in Krita are equivalent to channels in Photoshop.
Comment 7 Halla Rempt 2021-04-09 14:33:54 UTC
Well, yes and no. In very early versions of Photoshop (5 was the first version I got a manual for), you could add extra channels and they could be activated and function as a transparency mask. That functionality has never been removed, of course.
Comment 8 Srirupa Datta 2021-04-12 07:07:54 UTC
Okay, thanks, I guess I should learn a bit more about channels.

I did work on the warning as you said. Currently the warning shows: 
"The image has more than one transparency mask in a layer. For all layers having multiple transparency masks, only the rendered result will be saved." 

It's shown in case of exporting to psd, and not in case of png, jpg, and similar file formats.

Should I create a merge request or would you want me to add something?
Comment 9 Halla Rempt 2021-04-12 07:31:10 UTC
Please make a merge request -- if there are changes needed, it's easier to do that on the MR.
Comment 10 Srirupa Datta 2021-04-12 07:39:06 UTC
Okay, sure!

I'll let you know once it's done.
Comment 11 Bug Janitor Service 2021-04-12 11:52:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/801
Comment 12 Dmitry Kazakov 2021-04-16 13:21:27 UTC
Git commit c09df6581f5ffc04e684041aacb7afe0763d0aac by Dmitry Kazakov, on behalf of Srirupa Datta.
Committed on 16/04/2021 at 13:19.
Pushed by dkazakov into branch 'master'.

Warn when exporting layers with multiple transparency masks into .psd

Added MultiTransparencyMaskCheck.h that shows a warning message
whenever an unsaved, new document is exported to a file format
that doesn't support a layer with multiple transparency masks.
FIXED IN:5.0.0

M  +5    -0    libs/impex/KisExportCheckRegistry.cpp
A  +77   -0    libs/impex/MultiTransparencyMaskCheck.h     [License: LGPL(v2.0+)]

https://invent.kde.org/graphics/krita/commit/c09df6581f5ffc04e684041aacb7afe0763d0aac