Provide Scoured SVG as an option in Save As

Bug #409004 reported by codedread
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Wishlist
Unassigned

Bug Description

Inkscape should provide an option to save as Scoured SVG (see the scour script at http://launchpad.net/scour )

I have bundled this up as an Inkscape extension and tested in on OSX using Inkscape 0.47 pre.1. Simply unzip these 4 files into the extensions/ folder in the Inkscape distribution.

Tags: exporting svg
Revision history for this message
codedread (codedread) wrote :
Changed in inkscape:
status: New → Confirmed
Revision history for this message
codedread (codedread) wrote :

Hm, I forgot I have commit access :)

I've checked this in as of r21977.

Changed in inkscape:
status: Confirmed → Fix Committed
Revision history for this message
theAdib (theadib) wrote :

What is the difference in between scour and plain svg?

Revision history for this message
codedread (codedread) wrote :

Plain SVG only does the following:
- strips out metadata
- removes all inkscape/sodipodi extensions
- might leave in lots of things not even used (gradients?)

Scoured SVG does the following:
- leaves metadata in
- aggressively optimizes the SVG, see http://inkscape.svn.sourceforge.net/viewvc/inkscape/inkscape/branches/

Compare the following three identical paths:

Inkscape SVG:
<path
       sodipodi:type="arc"
       style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       id="path2816"
       sodipodi:cx="334.28571"
       sodipodi:cy="312.36218"
       sodipodi:rx="140"
       sodipodi:ry="102.85714"
       d="m 474.28571,312.36218 a 140,102.85714 0 1 1 -280,0 140,102.85714 0 1 1 280,0 z" />

Plain SVG:
<path
       d="m 474.28571,312.36218 a 140,102.85714 0 1 1 -280,0 140,102.85714 0 1 1 280,0 z"
       id="path2816"
       style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />

Scoured SVG:
<path d="m474.29,312.36a140,102.86,0,1,1-280,0,140,102.86,0,1,1,280,0z" fill="#F00" fill-rule="evenodd" id="path2816" stroke="#000" stroke-linecap="butt" stroke-linejoin="miter" stroke-width="1px"/>

Revision history for this message
Pablo Trabajos (pajarico) wrote :

codedread, your script seems to take extremely long time to process a file. Even small files take a surprising amount of time. I'm attaching a 2,5 MB file that is taking many minutes.

Revision history for this message
codedread (codedread) wrote :

Sorry, that link for scour's operations should have been: http://codedread.com/scour/ops.php

which describes all the optimizations that scour currently does.

For all but the most trivial images, scour will usually make a dramatic difference in file size (~50% reduction).

Revision history for this message
codedread (codedread) wrote :

Hello Pablo,

Yes, that file takes over 5 mins in scour. Here are my results:

Lithium-3:scour jschill1$ ./scour.py -i fulltests-candidates/regla.svg -o regla.svg
scour 0.18
Copyright Jeff Schiller, 2009
 File: fulltests-candidates/regla.svg
 Time taken: 322.216666667s
 Number of elements removed: 4195
 Number of attributes removed: 2943
 Number of unreferenced id attributes removed: 0
 Number of style properties fixed: 6853
 Number of raster images embedded inline: 0
 Number of path segments reduced/removed: 32
 Number of bytes saved in path data: 2812
 Number of bytes saved in colors: 665
 Number of points removed from polygons: 0
 Original file size: 2621215 bytes; new file size: 597394 bytes (22.79%)

As you can see, quite a bit of cruft is stuck in that file, the output file is reduced to 1/5th the original size. That is a significant savings (more than average on my test files).

Scour does a lot of processing, and that's going to take a lot of time. Scour *DEFINITELY* can be optimized, at the moment I haven't done any.

Revision history for this message
Pablo Trabajos (pajarico) wrote :

It finished processing the file and it went from 2561 KB to 585 KB, so I can confirm it works on Win XP (althought the performance could be improved).

Revision history for this message
codedread (codedread) wrote :

Pablo, just so I'm clear - do you consider that 2.5M file small? In my experience that's on the large side (in fact, it's the largest file I've ever run scour on). I may need to reset my expectations.

Scour's goal is to make the SVG files ready for display in a web browser. It's not necessarily appropriate to run scour against all SVG files. Suggestions on how to make that clear?

Revision history for this message
Pablo Trabajos (pajarico) wrote :

I consider that file rather big. The "Even small files take a surprising amount of time" line was related to other test with files under 100 KB.

I know that given that this output is just for exporting for web, the processing time is not a big issue. Also, the render speed gain and file size thinning is worth it.

> Suggestions on how to make that clear?
First of all, if the user is using that output format is because he already knows what is Scour for. And second, when closing, inkscape warns the user that the scour format may cause loss of data (like when you save in PDF, for instance).

On the long run, i'd like to see all the options of the script on a dialog window. That way the user could have better control about what to strip. Maybe Plain SVG should be merged with scour and let the user use a "Plain SVG" profile or any other created by him.

jazzynico (jazzynico)
Changed in inkscape:
importance: Undecided → Wishlist
milestone: none → 0.47
tags: added: exporting svg
ScislaC (scislac)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.