| Summary: | Document.exportImage doesn't export from the current state of the document | ||
|---|---|---|---|
| Product: | [Applications] krita | Reporter: | ioribranford |
| Component: | Scripting | Assignee: | Krita Bugs <krita-bugs-null> |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | normal | CC: | halla, rebecca |
| Priority: | NOR | ||
| Version First Reported In: | 4.2.8 | ||
| Target Milestone: | --- | ||
| Platform: | Appimage | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | Python script and kra for reproducing bug | ||
I have this problem intermittently. Does calling "doc.waitForDone()" before the export reliably save the issue? Disregard what I said aboveāI got confused. I do in fact get the issue every time, and neither calling doc.waitForDone() nor time.sleep(3) before the export solves the problem, nor does disabling batch mode. So it doesn't seem to be a timing issue as far as I can tell. Saving and re-opening does seem to be the only "fix". Ah, you have to explicitly refresh the projection. This works for me:
from krita import *
doc = Krita.instance().openDocument('/home/boud/bug-exportImage/bug-exportImage.kra')
doc.setBatchmode(True)
for layer in doc.rootNode().childNodes():
if layer.name() == "Layer 3": # has a drawing on it
layer.setOpacity(0)
doc.refreshProjection()
''' Workaround for bug: save, close, reopen
doc.save()
doc.close()
doc = Krita.instance().openDocument('bug-exportImage.kra')
doc.setBatchmode(True)
'''
# BUG? exports from last opened state, instead of saved or current
# so without above workaround, drawing is still visible in png
doc.exportImage('bug-exportImage.png', InfoObject())
doc.close()
|
Created attachment 126609 [details] Python script and kra for reproducing bug SUMMARY When calling Document.exportImage, the exported image matches the document when it was opened, not the document in its current state. Any modifications made in script before the export do not apply. STEPS TO REPRODUCE 1. Extract attachment files to home directory 2. Open Python script in Krita Scripter (opens kra, hides one layer and exports to png) 3. Run script 4. Open exported png OBSERVED RESULT The PNG image was exported with the hidden layer still visible EXPECTED RESULT The PNG image should be exported with the hidden layer invisible SOFTWARE/OS VERSIONS Linux/KDE Plasma: Ubuntu Bionic ADDITIONAL INFORMATION - Workaround is to save, close, and reopen the document after modification and before export. Saving alone does not work. - The exact same actions performed in the GUI work as expected.