Linux command
scour 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Optimize an SVG file
scour -i [input.svg] -o [output.svg]
Optimize with maximum compression
scour -i [input.svg] -o [output.svg] --enable-viewboxing --enable-id-stripping --enable-comment-stripping --shorten-ids --indent=none
Remove metadata and editor data
scour -i [input.svg] -o [output.svg] --remove-metadata
Indent output for readability
scour -i [input.svg] -o [output.svg] --indent=space
Process from stdin to stdout
cat [input.svg] | scour > [output.svg]
Show optimization statistics
scour -i [input.svg] -o [output.svg] -v
说明
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.
参数
- -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
- --enable-viewboxing
- Enable automatic viewBox creation from width/height
- --keep-editor-data
- Preserve Inkscape, Sodipodi, or Adobe Illustrator data
- --no-renderer-workaround
- Disable renderer bug workarounds
- --indent=_type_
- Indentation type: none, space, tab
- -v, --verbose
- Show statistics about optimization
- -q, --quiet
- Suppress non-error output
FAQ
What is the scour command used for?
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.
How do I run a basic scour example?
Run `scour -i [input.svg] -o [output.svg]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -i _file_, --input=_file_ do in scour?
Input SVG file (default: stdin)