Plugin Feasibility?

Discussion about writing code for Inkscape.
tfarnham
Posts: 1
Joined: Thu Jan 19, 2012 2:37 pm

Plugin Feasibility?

Postby tfarnham » Thu Jan 19, 2012 2:45 pm

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.

User avatar
LiquidAsh
Posts: 71
Joined: Fri Apr 22, 2011 11:35 pm
Contact:

Re: Plugin Feasibility?

Postby LiquidAsh » Thu Jan 19, 2012 11:15 pm

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.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Plugin Feasibility?

Postby ~suv » Sat Jan 21, 2012 4:04 am

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.
AFAIU the hook exists (input/output extensions hook into the file formats listed in the file dialogs for opening and saving).

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Plugin Feasibility?

Postby ~suv » Sat Jan 21, 2012 4:09 am

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


Return to “Programming”