This is a guide to making new extensions for Inkscape. Currently the majority of extensions are provided as python scripts.
The following extension types exist for Inkscape:
- input (read a file / data)
- output (write a file / data)
- effect (change contents in the document)
- print (output to an external device)
- C++ implementation (directly in code)
- scripts - e.g. python, perl or as system (console) scripts
- XSL transformations
User Interface and parameter types: Extension Definition File (INX)
All extensions are defined through Inkscape Extension Definition Files (.inx) which are XML files in the
namespace and described by the Relax NG available [here]
Extensions can be supplied with values obtained through easily definable parameters. Inkscape provides the basic GUI for user input. The following parameters are supported:
- int (for an integer number input field)
- string (for a text input field)
- float (for a float number input field)
- boolean (for a checkbox)
- enum (for a dropdown list)
- optiongroup (for a dropdown list or radio buttons)
- color (for a color selector, like the one in the Fill & Stroke dialog)
For the sake of the UI there are also the following two parameters that do not provide data to the extension but alter the user input GUI.
- description (for descriptions below parameters)
- notebook (for tabs)
See also: INX Parameters
The following mark-up:
<?xml version="1.0" encoding="UTF-8"?> <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>RadioButton example</_name> <id>org.inkscape.effect.radiobuttontest</id> <param name="radio1" type="optiongroup" _gui-text="Select option: "> <option value="string1">translatable string 1</option> <option value="string2">string 2</option> <option value="string3">test 3!</option> </param> <param name="radio2" type="optiongroup" _gui-text="Select second option: "> <option value="string11">string1</option> <option value="string22">string2</option> <option>test3!</option> </param> <effect> <object-type>all</object-type> <effects-menu> <submenu _name="Developer Examples"/> </effects-menu> </effect> ... </inkscape-extension>
Will result in the following GUI being created:
To allow the .inx files to fit snugly into Inkscape's i18n infrastructure some XML elements and attributes are prefixed with an underscore (_) character to indicate that the containing text should be marked for translation.
The extension script: a script written in the programming language of your choice
This guide isn't complete yet. If you would like to help write it, please contact the Inkscape web team via the inkscape-docs mailing list.
Until more information is available here, please take a look into the "extensions" folder of your Inkscape installation for examples. There you can find some .py files (foremost inkex.py) which supply you with some basic functionality (like error messages, getting ids of selected elements, etc.) you can build on with your extension, if you write it in Python. It is recommended to take a look at an extension that does something similar to what your new extension will do (e.g. modify path data, write a file, import a specific file format, send data to plotter or printer), to see how it could be done.
Github user Neon22 has compiled an example extension (Python, MIT licenced, available in 'Render' submenu) to support people who want to write new Inkscape extensions. It shows and explains the available options and can be used as a template for copy-pasting.
Some slightly older, unstructured information is also available on our Wiki:
- Extension subsystem
- Script extensions
- INX extension descriptor format
- Other related wiki articles
Sharing your extension
So you've written a new Inkscape extension for yourself now, to suit your own needs. Wouldn't it be great if others, who need the same, but don't know how to program, could also use your extension, and maybe give feedback to you, and suggest enhancements, or if other programmers could join you to help improve your extension?
To achieve this, you'll need to do the following:
- License your extension with an open source software license, e.g. GPL, like Inkscape.
- Publish your extension in a place where others can help with development, i.e. a website that allows developers to collaborate. If your extension contains files named similarly in other extensions (e.g. README, LICENSE), consider prefixing them with the name of your extension, so they do not overwrite other files when a user copies them into their extension directory.
- Make others aware of your extension by uploading it into your InkSpace gallery here at inkscape.org:
- First of all: don't worry too much about the code quality or the importance of the problem your extension can help solve. It might still be useful for someone - or someone may help you fix the issues, when they know about them.
- Upload your (archived, e.g. to zip format) extension files into the "Extensions" category:
- Add a helpful description that allows users without programming knowledge to understand what your extension does, with info about dependencies and the Inkscape versions and operating systems that you know your extension will work with.
- Also add a small thumbnail preview image (190x190px), which will help people understand what the extension is for.
- If applicable, add a link to the place where development of the extension happens
- To make sorting easier, it's helpful for users if you add a couple of tags (find a list of official tags that can be used at the right of this page, below the headings 'Version', 'Extension Type' and 'Platform'). If your extension does something that cannot be represented by any of the 'Extension Type' tags, please let us know, so we can add one that fits.
- Also fill in all the other fields in the upload form, then click on 'Publish'.
- Your upload will now be available for download on the extensions page.
- If you're up to it, send a short message to the user mailing list that tells people about the availability of a new extension. You can also ask for feedback.
- Watch how others enjoy using your extension, and, if you like to, engage with them to keep your extension updated and free of bugs.
- Try to remember to update your uploaded extension files in your inkscape.org InkSpace when you update the extension in your repository.