I wanted to use Krita as my Blender’s external texture painter software, which means editing, saving and alternating between Blender and Krita back and forth multiple times.
The problem is that saving a PNG image in Krita triggers the PNG Image / Export dialog every time, which can get tiresome in the workflow which requires saving sometimes multiple times per minute to check the changes in the 3D model in Blender.
So I found a simple way to bypass the dialog with a script by @Grum999 (see source below) and the “Ten Scripts” plugin.
Script
from krita import *
currentDocument = Krita.instance().activeDocument()
currentDocument.setBatchmode(True) # do not display export dialog box
pngOptions=InfoObject()
pngOptions.setProperty('compression', 5) # 0 (no compression) to 9 (max compression)
pngOptions.setProperty('indexed', False)
pngOptions.setProperty('interlaced', False)
pngOptions.setProperty('saveSRGBProfile', False)
pngOptions.setProperty('forceSRGB', True)
pngOptions.setProperty('alpha', True)
saved = currentDocument.exportImage(currentDocument.fileName(), pngOptions)
Usage
I saved the script as “KritaForceSavePNG.py” and added it to the 1st slot of the “Ten Scripts” plugin.
Make sure you already have a PNG image open.
If it’s a new image, first save it manually (Ctrl+S) as PNG and then from now on, just hit Ctrl+Shift+1 to execute the script and save it again instantly, bypassing the “PNG Image” dialog.
It’s impressive how the community comes together to find solutions for common workflow challenges. Your initiative in finding and implementing this script can benefit many others facing similar issues.
Thanks for sharing your workaround for bypassing the PNG Image/Export dialog in Krita! Workflow efficiency is key, especially when switching between Blender and Krita frequently. Streamlining the process with scripts can save a lot of time and hassle.
Speaking of optimization, you can also try to compress image files for faster saving and sharing. Tools like this can help you reduce file sizes without compromising quality. This can be particularly useful when dealing with multiple iterations of image editing and saving throughout your workflow.
The OP wants to handle PNG’s, a JPG-Optimizer is not of help there, and every transformation of JPG’s introduces losses in image-quality. So I would transform them as rarely as possible.
Here one can use PNG optimization tools, and there are a lot out there for every OS.
For Windows, I highly recommend RIOT (Radical Image Optimization Tool), but it runs via WINE or WineBottler under Linux and macOS too.
It is a versatile tool allowing size-reduction of pictures in JPEG, WEBP, GIF and PNG-Format, you can adjust the rate of compression for every format, it offers several algorithms for PNG’s, offers a side-by-side view to see what your pics will look after optimization (WYSIWYG) and shows an approximate size of your pic after optimization. A batch-mode is also implemented, and you can get Plugins for XNView and GIMP and more, like IrfanView*, for instance, can be bound in if you know a little coding.
Plus it is free of charge, but you can donate if you like.
Michelist
*For IrfanView exists also an older Plugin, if it works with newer versions of RIOT is unknown to me.