- Install Python and
pip
- Install the Python program named
scour
pip install scour
- Run this program on files with the example script below.
Last active
September 2, 2021 12:36
-
-
Save oclero/a0438ea27754ecf9a9e3027ef1940e98 to your computer and use it in GitHub Desktop.
How to optimize SVG files with Powershell and scour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$files = Get-ChildItem $args[0] -Filter "*.svg" | |
foreach ($file in $files) { | |
$fileName = $file.Name | |
$filePath = $file.FullName | |
$fileDir = $file.DirectoryName | |
$outputFilePath = "$fileDir\build\$fileName" | |
scour -i "$filePath" ` | |
-o "$outputFilePath" ` | |
--enable-viewboxing ` | |
--enable-id-stripping ` | |
--enable-comment-stripping ` | |
--shorten-ids ` | |
--no-line-breaks ` | |
--remove-descriptive-elements ` | |
--strip-xml-prolog ` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment