Batch optimize with Scour possible?

Post questions on how to use or achieve an effect in Inkscape.
benfrain
Posts: 2
Joined: Wed Feb 13, 2013 7:07 pm

Batch optimize with Scour possible?

Postby benfrain » Wed Feb 13, 2013 7:13 pm

I'm slowly getting up to speed with both SVGs and Inkscape. Apologies if this is obvious...

Is it possible to batch optimize images in a folder from the command line using Inkscape/Scour? I have around a hundred small (<10KB) images that I want to optimise and would like to around the tedium of opening and saving each one out.

I was hoping to move to the relevant folder and do something like this:

Code: Select all

python scour.py -i *.svg -o /optimized


Is such a thing possible (I'm on OS X if that matters)?

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Batch optimize with Scour possible?

Postby brynn » Fri Feb 15, 2013 12:53 am

Image
Welcome to InkscapeForum!

Well I wasn't going to try to answer this message, since I don't know much about using the command line. But out of curiosity about Scour, I did some searching. On this page I found this:

"Command Line Script

To run scour on the command-line, first download and install Python, then download scour. The basics are:

$ python scour.py -i input.svg -o output.svg

In addition, you can use compressed svg (.svgz) on the input and output and scour will decompress/compress automatically."


I don't think that's for a batch operation. And you've probably already seen that page. But just in case, I thought I'd post it.

All best :D

benfrain
Posts: 2
Joined: Wed Feb 13, 2013 7:07 pm

Re: Batch optimize with Scour possible?

Postby benfrain » Fri Feb 15, 2013 3:24 am

Hi Brynn,

Yes, that's the default way of using Scour on the command line (although obviously it's built into Inkscape when you do save optimised SVG from the GUI). Sadly, it doesn't seem to like batch operations though. I'm certain there is a way to do it, I'm just not sure what the correct syntax is.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: Batch optimize with Scour possible?

Postby ragstian » Fri Feb 15, 2013 3:53 am

Hi benfrain

No need to run scour as scour is part of Inkscape (after v0.47?).
Just use the -l, --export-plain-svg=FILENAME and --vacuum-defs command line switches running Inkscape from the command line
http://inkscape.org/doc/inkscape-man.html

Report back if you need help making a script (batch file) to process your files.
( It would then be nice to know you OS )

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

quatrecouleurs
Posts: 2
Joined: Thu Nov 05, 2015 1:39 am

Re: Batch optimize with Scour possible?

Postby quatrecouleurs » Thu Nov 05, 2015 1:45 am

Sorry duplicate
Last edited by quatrecouleurs on Thu Nov 05, 2015 8:36 am, edited 1 time in total.

quatrecouleurs
Posts: 2
Joined: Thu Nov 05, 2015 1:39 am

Re: Batch optimize with Scour possible?

Postby quatrecouleurs » Thu Nov 05, 2015 7:41 am

Dear all,
Here is a way to do it in bash shell:

Code: Select all

find . -name "*.svg" -exec scour -i {} -o {}.svg2 \;

It searches for all the *.svg files in the current folder (.), executes for each match ( {} ) scour, then saves with a .svg2 appended extension. This way you keep the original files for comparaison matters, and if the scoured ones are good to go you can then use a bash script or a gui renaming tool to remove the svg2 extension.

Off course, you can add any scour parameters, for instance just before the closing \; to know more please type scour -h.

Hope it helps !


Return to “Help with using Inkscape”