batch simplify svgs

Post questions on how to use or achieve an effect in Inkscape.
Lars_Bylund
Posts: 7
Joined: Mon Nov 28, 2011 9:35 am

batch simplify svgs

Postby Lars_Bylund » Sat May 26, 2012 9:36 pm

hi all!

I have been using the command line to convert .avi video to png's, autotrace the png's to svg, convert the svg's to png and finally convert the png's back to avi.

why?

for several reasons, I like the look of the result, you can 'scale' a small video into HD.

here's an example of the end result. WATCH IN FULL HD, please :)
http://www.youtube.com/watch?v=R8zW2MHhgUE

Up until now, I have not been using inkscape, in this process, but It is my tool of choice for drawing and tracing svgs by hand, I love it!

THE QUESTION!

I need to simplify (all paths in) around 3000 svgs, I really like the way the Simplify tool works in inkscape, but doing this manually would be time and coffee consuming.

How can I batch simplify a bunch of svg's using inkscape simplify in the command-line?

Lars

Uktrunie
Posts: 154
Joined: Sun Jul 18, 2010 4:48 am

Re: batch simplify svgs

Postby Uktrunie » Sun May 27, 2012 3:54 am

Are you in Windows? If so, you can write this in the command line:

for %n in (*.svg) do inkscape --file="%n" --verb=EditSelectAll --verb=SelectionSimplify --verb=FileSave --verb=FileClose

If your're in Linux or Mac, then I'll have to try how to do that, cos I've no idea. :) The part that loops through files is the one that would change, the "inkscape --file..." would be the same.

User avatar
Xav
Posts: 1209
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: batch simplify svgs

Postby Xav » Sun May 27, 2012 7:11 pm

Fairly similar in Linux (note that this is all one line - the forum software wraps it on my screen):

Code: Select all

for n in *.svg; do inkscape --file="$n" --verb=EditSelectAll --verb=SelectionSimplify --verb=FileSave --verb=FileClose; done


Two things to note:
1) I haven't tried this, I've just converted the FOR loop from Uktrunie's reply into Bash format for the most common Linux shell
2) Linux filesystems are usually case sensitive, so this won't work if your files have "SVG" as the extension, rather than "svg". You can change the *.svg accordingly, or modify it to *.[sS][vV][gG] to catch any mixture of cases.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

Uktrunie
Posts: 154
Joined: Sun Jul 18, 2010 4:48 am

Re: batch simplify svgs

Postby Uktrunie » Mon May 28, 2012 3:12 am

Well, mine works. The only thing that doesn't quite work is that you'll see the Inkscape window opening and closing for every file. There's an option that you can add to that line, --without-gui, but for what I read, it doesn't work in Windows (it does work in Linux)

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

Re: batch simplify svgs

Postby ~suv » Mon May 28, 2012 6:10 pm

Uktrunie wrote:The only thing that doesn't quite work is that you'll see the Inkscape window opening and closing for every file. There's an option that you can add to that line, --without-gui, but for what I read, it doesn't work in Windows (it does work in Linux)

Adding '--without-gui' won't help with the mentioned task on Linux either: if you want to use verbs from the command line Inkscape needs to open a GUI window, else the verbs are not executed (this is independent of the platform inkscape is running on). On linux could can use Xvfb and set $DISPLAY for the inkscape command line process to the one of the virtual frame buffer, if you want to "hide" the Windows from the current display.

Lars_Bylund
Posts: 7
Joined: Mon Nov 28, 2011 9:35 am

Re: batch simplify svgs

Postby Lars_Bylund » Tue May 29, 2012 8:01 pm

thank you all, it seem to work, except for that the gui opens... and I guess that's a bit processor and ram consuming, so if anyone know of a way, or another program/ solution, please let me know.

I have tried SVG Cleaner, but it gives really strange results.

by the way, is there some other vector graphics forum out there, that deals with vector graphics, without beig tied to a specific program?

Lars


Return to “Help with using Inkscape”