I would like to write a plugin in python that would perform the following functions and would like feedback on which items are feasible.
1) Automatically run my sript on saving of the main svg project file (Save Hook).
2) Upon save, rasterize the svg file into segmented images. So if the document is 5000 x 50, I want to make one hundred 50x50 images and save those images to individual files.
3) If hooking the save is not feasible, can I instead add a toolbar button that users would press to perform #2...I find the extensions menu large and somewhat cumbersome.
Thanks.
Plugin Feasibility?
Re: Plugin Feasibility?
1) I believe that the built in extension system only seems to allow running extensions from the extension menu. I think you'll have to poke through the source code of Inkscape to add this kind of hook.
2) Answer above + extensions receive vector data to operate on, so you'll have to rasterize it yourself. Or, you might be able to have your script run Inkscape from the command line to get some of this done (I still haven't explored the command line options very deeply yet).
3) I believe that changing the toolbar icons still requires making source code changes at this point, so no. If you want to make the extensions menu shorter, you could try moving all of the default extensions into a separate sub-menu/folder. Also, you can leave your extension window open/docked while you work so the apply button is more accessible.
I'm sorry these answers aren't more encouraging.
2) Answer above + extensions receive vector data to operate on, so you'll have to rasterize it yourself. Or, you might be able to have your script run Inkscape from the command line to get some of this done (I still haven't explored the command line options very deeply yet).
3) I believe that changing the toolbar icons still requires making source code changes at this point, so no. If you want to make the extensions menu shorter, you could try moving all of the default extensions into a separate sub-menu/folder. Also, you can leave your extension window open/docked while you work so the apply button is more accessible.
I'm sorry these answers aren't more encouraging.
Re: Plugin Feasibility?
AFAIU the hook exists (input/output extensions hook into the file formats listed in the file dialogs for opening and saving).LiquidAsh wrote:1) I believe that the built in extension system only seems to allow running extensions from the extension menu. I think you'll have to poke through the source code of Inkscape to add this kind of hook.
Re: Plugin Feasibility?
LiquidAsh wrote:2) Answer above + extensions receive vector data to operate on, so you'll have to rasterize it yourself. Or, you might be able to have your script run Inkscape from the command line to get some of this done (I still haven't explored the command line options very deeply yet).
Take a look at the output extension for 'GIMP XCF maintaining lyers (*.xcf)' [1]: extension scripts can call inkscape from the command line to export to bitmap e.g. by id.
[1] files for XCF output extension in current trunk: gimp_xcf.inx, https://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/share/extensions/gimp_xcf.py