Scour - An SVG Optimizer / Cleaner
Find a file
Eduard Braun c698522c28 Simplify and fix "removeComments()"
* The separate treatment of comments at the documentElement's level is not necessary - they have a parent (as tested in Python 3.5.0 and 2.7.11 and 2.6.6)! It might not have worked before due to a typo - note the "if isinstance(element,...)" and "len(element.data)" which should both refer to "subelement" instead - or a bug in very old versions of Python).
* Fix the iteration over childNodes (i.e. replace "for subelement in element.childNodes:" with ""for subelement in element.childNodes[:]:". We have to create a copy of the list to iterate over, otherwise we'd be iterating over a list as we change it which leads to unpredictable results.

Fixes #25
2015-12-10 22:51:27 +01:00
scour Simplify and fix "removeComments()" 2015-12-10 22:51:27 +01:00
unittests Unittests: Account for b979fe19e5 (fix one test and add two more) 2015-12-07 00:33:08 +01:00
.gitignore initial source import (v0.26) and packaging 2013-10-22 16:31:42 +02:00
LICENSE initial source import (v0.26) and packaging 2013-10-22 16:31:42 +02:00
Makefile fix links; only upload source dist 2015-11-16 18:12:56 +01:00
README.md add notice of repo move 2015-10-17 17:29:47 +02:00
scour.sublime-project initial source import (v0.26) and packaging 2013-10-22 16:31:42 +02:00
setup.py fix links; only upload source dist 2015-11-16 18:12:56 +01:00
testcss.py Unittests: Fix warnings 2015-12-06 22:13:21 +01:00
testscour.py Unittests: Account for b979fe19e5 (fix one test and add two more) 2015-12-07 00:33:08 +01:00

Scour

Scour is a Python module that takes an input SVG and outputs a cleaner, more concise SVG file. The goal is that authors will use this script after editing the file in a GUI editor such as Inkscape or Adobe Illustrator.

Scour was started as a vehicle for me to learn Python. In addition, the goal is to reduce the amount of time I spend in cleaning up files I find on sites such as openclipart.org

Ideas are pulled from three places:

Regards,

Jeff Schiller, 2009-04-06

codedread@gmail.com

http://blog.codedread.com/

http://www.codedread.com/scour/

Usage

Standard:

scour -i mysvg.svg -o mysvg_opt.svg

Better (this works in IE which needs Viewbox):

scour -i mysvg.svg -o mysvg_opt.svg --enable-viewboxing

Maximum:

scour -i mysvg.svg -o mysvg_opt.svg --enable-viewboxing --enable-id-stripping \
      --enable-comment-stripping --shorten-ids --indent=none

Maximum + Compress:

scour -i mysvg.svg -o mysvg_opt.svgz --enable-viewboxing --enable-id-stripping \
      --enable-comment-stripping --shorten-ids --indent=none

Notes

Packaging from sources retrieved on 2013/20/22:

  • done by Tavendo GmbH, Tobias Oberstein
  • license same as upstream (Apache 2.0)
  • now official repo, please see here