Help starting script to export select layers

Hi

If it can help you, here InfoObject I use for PNG/JPEG export:

color=QColor('#ff9966')
pngOptions=InfoObject()
pngOptions.setProperty('compression', 9)        # 0 (no compression) to 9 (max compression)
pngOptions.setProperty('indexed', False)        # True to use indexed palette    
pngOptions.setProperty('interlaced', False)     # True to use interlaced 
pngOptions.setProperty('saveSRGBProfile', True) # False to not use sRGB profile
pngOptions.setProperty('forceSRGB', True)       # False to not use convert to sRGB
pngOptions.setProperty('alpha', True)           # False to not save alpha channel
pngOptions.setProperty('transparencyFillcolor', [color.red(), color.green(), color.blue()])

jpgOptions=InfoObject()
jpgOptions.setProperty('quality', 85)           # 0 (high compression/low quality) to 100 (low compression/higher quality)
jpgOptions.setProperty('smoothing', 15)         # 0 to 100    
jpgOptions.setProperty('subsampling', 2)        # 0=4:2:0 (smallest file size)   1=4:2:2    2=4:4:0     3=4:4:4 (Best quality)
jpgOptions.setProperty('progressive', True)             # False for non pogressive JPEG file
jpgOptions.setProperty('optimize', True)
jpgOptions.setProperty('saveProfile', True)             # False to not save icc profile
jpgOptions.setProperty('transparencyFillcolor', [color.red(), color.green(), color.blue()])


currentDocument=Krita.instance().activeDocument()
currentDocument.setBatchmode(True)              # do not display export dialog box
saved = currentDocument.exportImage("test.png", pngOptions)
saved = currentDocument.exportImage("test.jpeg", jpgOptions)

Grum999

4 Likes