I have a downloaded vector file (AI format). The file contains simple vector images of various dog breeds. I’ve loaded the file in inkscape,ungrouped them and would like a way to save out each dog vector as a separate file. Is there a way to automate this with Inkscape or some other OS/Freeware tool? Otherwise I’ll have to select each and Save as. Any help is most appreciated!
UPDATE Thanks to JSBueno for the advice on editing the actual SVG file. I didn’t realize that SVG was just an XML file. I should be able to easily walk through the file and export out each dog as a separate file. This, by the way, will be way faster than doing it through the interface which was the goal of this post. Thanks to all for the advice.
Answer
There are two solutions that I have found for exporting multiple objects from Inkscape as SVGs. These methods have the benefit of being scripts that can be run automatically and don’t need editing of SVGs in text editors.
The svg-objects-export script works by exporting all objects based on regular expressions. In your case it would work by exporting all objects with a particular ID. To use it first clone or download the script from Github.
In Inkscape you need to change the ID of all the objects you want exporting to have the same filename pattern. To do this open the Object Properties dialogue by going to Object > Object Properties or pressing Ctrl+Shift+O. In the ID field change them all to have the same basename ID e.g. Dog_1
, Dog_2
, Dog_3
etc (objects cannot have the same ID).
With the file saved and the script downloaded, in a terminal run the following command
python svg-objects-export.py --pattern 'Dog_*' /path/to/your/file.svg
This will export all of the objects with the basename ID “Dog_”.
The inx-exportobjects inkscape extension will simply export all selected objects. To use it first clone or download the extension from Gitlab. To install it copy the files export_objects.inx
and export_objects.py
to .config/inkscape/extensions/
. In Inkscape you’ll have an option called “Objects to Files…” in Extensions > Exports. Select the objects you want to install and select this option.
In this dialogue box simply change the Export Directory to the place where you want to save your files and change the Basename to the new name of the files and then press Apply.
The files will be exported to your specified directory.
Each of the solutions have many other options, such as animated gif export, which you should definitely experiment with.
Attribution
Source : Link , Question Author : dinki , Answer Author : chicks