Thursday, February 14, 2019

games - How to Batch-export layers of Inkscape-generated SVG-file to Bitmap for sprites?


Batch -export means that I may need to add certain transformations such as anti-alias, contrast-fixes and resizing. SVG here means I am using Inkscape. One layer here is a sprite. I currently export each layer individually to bitmap, File > Export Bitmap -- but it is time-consuming.


enter image description here




  1. Is there some way to programmatically batch-export layers from SVG-file?





  2. Or does there exist some batch-export-button in Inkscape?




  3. I specially need the same custom area for each sprite, the same as clicking many times the menus but it is stupid -- perhaps some macro for this?





Answer



Thanks to Freenode's #inkscape channel, the user su_.* and verbalsh.*. su_.* provided most of the below ideas. Please, notice that exporting to raster means an information loss. Besides, Inkscape has odd features such as anti-alias-always-on-in-exportation -feature and odd no-control-with-contrast-in-exportation -feature, meaning an extra information -loss. su_.* mentioned in this context: "always antialiased, same renderer as on-canvas".


According to su_*, "an earlier answer by the author of JessyInk to a related question" is here where you export each layer together with a common background -layer (which defines bg color or maybe export size).


Related feature requests






  • "Optionally disable anti-aliasing for bitmap export" -thread here or the newer "Kill anti-aliasing for bitmap export" -thread here




  • Granular PNG Export Options here




  • 'Feature Request - Export Layers to PNG sequence…' (GUI, mostly) here





  • 'Selectively Export layers from Command Line Interface' - already doable AFAIU with '--export-id' here





Solution candidates






  • JessyInk: "extension bundled with Inkscape to create a layers-based presentation, which includes an output format (via 'Save') called 'JessInk zipped pdf or png putput (.zip)"*. It "can create a zip archive optionally with a PDF or PNG per layer". More here.




  • "[E]xport by id from the command line" but there are some problems such as extra-work in hiding the other layers "if the sprites are all on top of each other". A sample shell script to export each layer to png here.




  • "[D]efine the export areas on the command line", more here.




  • [Novel idea] "another external extension (designed to create animations) also can batch export each layer to bitmap", more here.






References





  1. Inkscape manual about exportation here.





  2. Command line -usage instructions with $ inkscape --usage.





No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...