LinuxCommandLibrary

scour

TLDR

Optimize an SVG file

$ scour -i [input.svg] -o [output.svg]
copy
Optimize with maximum compression
$ scour -i [input.svg] -o [output.svg] --enable-id-stripping --enable-comment-stripping --shorten-ids
copy
Remove metadata and editor data
$ scour -i [input.svg] -o [output.svg] --remove-metadata
copy
Indent output for readability
$ scour -i [input.svg] -o [output.svg] --indent=space
copy
Process from stdin to stdout
$ cat [input.svg] | scour > [output.svg]
copy
Show optimization statistics
$ scour -i [input.svg] -o [output.svg] -v
copy

SYNOPSIS

scour [options] [-i input.svg] [-o output.svg]

DESCRIPTION

Scour is a Python-based SVG optimizer that reduces file size by removing unnecessary data and optimizing structure. It cleans "cruft" added by SVG editors while maintaining identical visual rendering.
Optimizations include removing unused elements and attributes, shortening numeric values, collapsing groups, and converting shapes to paths. The tool is designed for preparing SVGs for web deployment or further processing.
Scour performs lossless optimization by default, preserving the visual appearance of the original file. More aggressive options may alter structure but should not affect rendering.

PARAMETERS

-i file, --input=file

Input SVG file (default: stdin)
-o file, --output=file
Output SVG file (default: stdout)
-p digits, --set-precision=digits
Number of significant digits for coordinates
--enable-id-stripping
Remove unreferenced ID attributes
--enable-comment-stripping
Remove all comments
--shorten-ids
Replace IDs with shorter versions
--remove-metadata
Remove metadata elements
--indent=type
Indentation type: none, space, tab
-v, --verbose
Show statistics about optimization
-q, --quiet
Suppress non-error output

CAVEATS

Never overwrite original files; Scour changes document structure and semantics. Hand-edited SVGs may not produce optimal results since Scour is designed for editor-generated files. Some optimizations may cause issues with specific SVG viewers or processors.

HISTORY

Scour was originally created by Jeff Schiller and Louis Simard as an open-source tool for SVG optimization. It became popular in the Inkscape community and is now maintained by Tobias Oberstein and Patrick Storz. Licensed under Apache-2.0.

SEE ALSO

svgo(1), inkscape(1), convert(1), xmllint(1)

Copied to clipboard