berteh / svg-objects-export

Export multiple SVG elements to other formats (png, pdf, ps, eps, svg), selecting them based on their ID with regular expressions, or XPath expression.
115 stars 29 forks source link

Can be done with just inkscape? #27

Open hoijui opened 4 years ago

hoijui commented 4 years ago

I think it can, if you have a look at man inkscape, and then look for --export-id.

I wanted to use this, because I though it would export all objects into a single file, which is what inkscape can't do, but neither does this script.

still.. thanks for making it available! :-)

berteh commented 4 years ago

Hello hoijui, I don't understand your question/problem. This script can indeed be used to export each object to a single file, if you want, or just a subset, like groups or anything else... as long as you can expresse which objects you want to export.

hoijui commented 4 years ago

Sorry! It was indeed badly written (I was tired). What I mean to say is, that I think what this script does, can be done with inkscape alone (see man page extracts below). I am using that, and it works. So I was wondering, if this script may provide something extra, or if it was made at a time where inkscape was not yet able to do that or ... something else I can't think of.

What I was looking for when I found this script, was something that could extract multiple objects into a single file, which inkscape can not do directly (though some BASH scripting makes it possible).


-i ID, --export-id=OBJECT-ID[;OBJECT-ID]*

For PNG, PS, EPS, PDF and plain SVG export, the id attribute value of the object(s) that you want to export from the document; all other objects are not exported. By default the exported area is the bounding box of the object; you can override this using --export-area (PNG only) or --export-area-page.

If you specify many values with a semicolon separated list of objects, each one will be exported separately. In this case the exported files will be named this way: [inputfilename][ID].[export_type]


-j, --export-id-only

For PNG and plain SVG, only export the object whose id is given in --export-id. All other objects are hidden and won't show in export even if they overlay the exported object. Without --export-id, this option is ignored. For PDF export, this is the default, so this option has no effect.


berteh commented 4 years ago

Thanks for clarifying.

Indeed this script was written when Inkscape's '-i' option could handle only a single ID.

It does support additional selection/export based on the (XML) element though, that's not (yet?) in Inkscape (see -x option) and selection through pattern In the IDs (see -p option), and selection through exclusion (you just select the objects you don't wanna export, the script exports all others).

See examples: https://github.com/berteh/svg-objects-export#examples

So you can choose to export all layers, or all groups, or all rectangles, or all objects that contain 'small' in their name string (not only their ID!) or all that at the same time... without knowing these objects IDs... and with no need to modify your batch line each time you add one such object in your SVG file.

But maybe someday it will all be included in Inkscape, I don't know... And that's the beauty of opensource :-D

Hope this helps. Berteh.

berteh commented 4 years ago

More examples in the wiki (some more advanced)... but your imagination is the limit: https://github.com/berteh/svg-objects-export/wiki#usage-examples

If you turn out using this script don't hesitate to share your favourite command line there!

hoijui commented 4 years ago

thanks @berteh ! :-) so really, it was just not exactly that simple thing I wanted, but still has a lot of benefit, even over the current inkscape.. great! :-) I guess.. it would make sense for me to use it somehow, but as I have it working without it and .. it is not the most important piece of software (that thing I wrote), I'll leave it at that. I will need to do more with SVG filtering though, and might come back to this then.

thank you! great interacting with you. :-)