Bug 404615

Summary: Dimensions of Images output by "Export Layers" vary wildly depending on the layers alpha
Product: [Applications] krita Reporter: bradsummerquist
Component: ScriptingAssignee: vanyossi <ghevan>
Severity: normal CC: ghevan, rebecca, scottpetrovic
Priority: NOR    
Version: 4.1.7   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Attachments: this has three layers, each layer will have high variation in dimensions when exported via the Export-Layers script.
Quick fix patch

Description bradsummerquist 2019-02-20 19:14:10 UTC
Created attachment 118230 [details]
this has three layers, each layer will have high variation in dimensions when exported via the Export-Layers script.


scripts->"Export Layers" downsizes the exported image dimensions, depending on the alpha values of the layer.  This is most apparent when the layer has fully transparent pixels around the border of the image. 

1. Create a 1024x1024 px krita document. 
2. Clear all the layers so that you have a completely transparent document. 
3. Paint a small (for example, 2 pixel by 2 pixel) black dot in the center of the image. 
3. Run the export layers command (from Tools->Scripts->"Export Layers") on the recently created document/layer. 
4. inspect the images that were output by the 'Export Layers' script. 


The output images are down-sized depending on the layer's alpha.  So, if you only have a 2px-by-2px dot in the layer, the output image size is 2px by 2px. 


We'd expect the dimensions of the output image to have the same dimensions as the images in the document (1024x1024, in the case of the repro steps).  That's the way that 'File->Export' works. 

If the downsizing is a 'feature', we'd expect the feature to be configurable via the "Export Layers" dialog box (it currently isn't). 

Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 


project that repros this is attached, just open it and run "Tools->scripts->export layers"
Comment 1 bradsummerquist 2019-03-09 03:29:38 UTC
I believe this was fixed on December 25th, when an InfoObject parameter was added to the 'Node::Save()' method.  

I haven't been able to confirm or deny because I can't get python scripts running on the nightly builds (I haven't investigated too deeply on why this is).
Comment 2 Rebecca Breu 2019-03-09 09:46:01 UTC
No, the issue is still there. I fixed the export layers script recently so that it doesn't crash anymore with the InfoObject API change, but I guess the way I did it just restored the original behaviour. I will play around with it a bit.
Comment 3 Scott Petrovic 2019-04-05 15:20:50 UTC
it looks like Rebecca has confirmed this is still a bug and is looking into it. marking this as confirmed.
Comment 4 vanyossi 2019-04-15 04:59:02 UTC
Created attachment 119414 [details]
Quick fix patch

The save function in Node.cpp uses current layer bounds to create new image to save, this is what causes the layer to only export cropped size.

The patch attached is a quick fix, but if its ok, I can push it later.
Comment 5 vanyossi 2019-04-24 06:14:07 UTC
Git commit de7fef16da3da6ce2bc690947fd70dc91f27a91f by Ivan Yossi.
Committed on 24/04/2019 at 06:14.
Pushed by ivany into branch 'master'.

Allow selecting boundary limits on python export

save, now accepts an optional bouding region to set
export area.

Differential Revision: https://phabricator.kde.org/D20573

M  +2    -2    libs/libkis/Node.cpp
M  +4    -1    libs/libkis/Node.h
M  +1    -1    plugins/extensions/pykrita/sip/krita/Node.sip
M  +35   -13   plugins/python/exportlayers/uiexportlayers.py