Currently Krita lacks an ability to export a selected region.
It often needs some precise cropping to remove unwanted areas, to make the eyes stay easier on the important parts of the artwork.
Currently, I achieve that with a group layer, consisting an erase layer on top and a color filled layer at the bottom. Then I select the region of the erase layer and then copy and paste my whole work as a new file and then export.
The problem is that this is very resource intensive when I have a lot of layers. It takes time to copy the layers, and it doubles the memory use.
Update: Also I want to keep the whole workflow inside a single file, because switching from one file to each other takes some time, and it would be cumbersome if I am trying different crops or edits.
Nice idea with this file layer! I think this is excellent if you don’t want to commit to a specific crop as you keep working on your piece.
Maybe I’m misunderstanding the problem, but this issue seems contrived to me. I would also consider these methods:
select a rectangle area, copy merged and paste into a new image. This should have the same cost regardless of the layers
save a backup copy (you can close the document and work on that copy too), keep doing crop-undo until you are satisfied. Can also flatten first if it helps the performance.
The thing is, especially in the world of FOSS (Free and Open Source Software), where Krita belongs to, that it can take time for a solution to be implemented, so we try to offer at least workarounds for the time you have to wait for your feature.
But before a feature is considered worth implementing, interest must be shown in it. This means that the users should vote on this wish, especially you as the one who wants it, should cast your vote in your opening post to the left of your heading, because why work on a feature that nobody is interested in?
Yeah I implemented an export that does this on one of my plugins because I was seriously tired of the current setup with exporting and lack of context sensitivity.
I have stopped using exports and only use save for KRA files now. It’s very limited but you really don’t need more.
The export of selected region can be achieved by using couple of Krita actions and a little bit of scripting:
import os
from datetime import datetime
from PyQt5 import QtWidgets
from krita import Krita
def timestamp():
return datetime.now().strftime("%Y%m%d-%H%M%S-%f")[:-3]
def go():
doc = Krita.instance().activeDocument()
if doc is None:
return
selection = doc.selection()
if selection:
if selection.width() * selection.height() == 0:
msg = "Seems that your selection is invalid."
QtWidgets.QMessageBox.warning(None, "Warning", msg)
return
else:
QtWidgets.QMessageBox.warning(None, "Warning", "No valid selection to export")
return
directory = str(
QtWidgets.QFileDialog.getExistingDirectory(None, "Select Directory", "")
)
if not directory and not os.path.exists(directory):
return
w, h = selection.width(), selection.height()
file_name = f"{timestamp()}-{w}-{h}.png"
file_full_path = os.path.normpath(os.path.join(directory, file_name))
Krita.instance().action("copy_merged").trigger()
Krita.instance().action("paste_new").trigger()
new_doc = Krita.instance().activeDocument()
new_doc.setBatchmode(True)
new_doc.saveAs(file_full_path)
new_doc.waitForDone()
new_doc.close()
new_doc.waitForDone()
new_doc.setBatchmode(False)
go()
The drawback is obviously the need to choose the directory all the time. This can be avoided by hardcoding the path in the variable directly. Actuators Variables and Sequences can help with tediousness.