Bug 405366 - Flatten image with alpha inheritance in python results in a blank image.
Summary: Flatten image with alpha inheritance in python results in a blank image.
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Tiar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-11 19:38 UTC by wolthera
Modified: 2019-03-27 21:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
File to open with the script. (50.42 KB, application/x-krita)
2019-03-13 13:14 UTC, wolthera
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wolthera 2019-03-11 19:38:30 UTC
SUMMARY
While alpha inheritance merging using layer->flatten image now works, it doesn't work with document.flatten().

STEPS TO REPRODUCE
Run this python script, open a file with alpha ineheritance in its layer stack:

------------------------------------------
from krita import *
from PyQt5.QtWidgets import QFileDialog

# Open a file, flatten it, add a view to the krita instance.
filename = QFileDialog.getOpenFileName(caption="Open File", filter="Krita files (*.kra)")[0]
doc =  Application.openDocument(filename)
doc.waitForDone()


# Now we'll add a new view.

Application.activeWindow().addView(doc)

# Now we'll flatten
doc.flatten()
doc.waitForDone()

------------------------------------------

OBSERVED RESULT

Everything is blank


EXPECTED RESULT

Image, but flattened to a single layer.
Comment 1 Tiar 2019-03-13 09:30:28 UTC
Works for me... could you please include a file that gives you that behaviour? I'll checked with my test files for similar problems and they all worked.

(In the previous issue like that: BUG 405119 the problem was when the layer inside of the group was selected, nothing special about alpha inheritance; so in this case, I checked saving my test files with different layers selected and none gave me the issue, that's why I need exactly the same file that gives you issues to make sure the same layer is selected and located in the same combination of layers and groups).
Comment 2 wolthera 2019-03-13 13:14:32 UTC
Created attachment 118771 [details]
File to open with the script.


This file reproduces the bug with Krita Version: 4.2.0-pre-alpha (git 52ee93a) on KDE Neon.
Comment 3 Tiar 2019-03-20 13:30:02 UTC
Confirmed. 

The only thing is, alpha inheritance probably doesn't matter that much. If you disable alpha inheritance in the image and save and try to flatten with the provided python script, the result is incorrect, too.

Also, since the test image has non-transparent background color, the result is also incorrect because of bug 405684 . It's unrelated to the missing content problem here, though.
Comment 4 Tiar 2019-03-25 10:23:37 UTC
Can you please check whether it works for you now on master? It looks to me like it was fixed by c7a921d1b7b5e6a.

Also (in case the future proves it needs more investigation) if you tried even before the commit mentioned to first open an image (in one script) and then flatten the image (in another script), it worked. The projection of the layers were not updated for some reason if you tried to flatten just after opening.
Comment 5 wolthera 2019-03-27 21:28:55 UTC
Fixed