Skip to content

Instantly share code, notes, and snippets.

@oclero
Last active September 2, 2021 12:36
Show Gist options
  • Save oclero/a0438ea27754ecf9a9e3027ef1940e98 to your computer and use it in GitHub Desktop.
Save oclero/a0438ea27754ecf9a9e3027ef1940e98 to your computer and use it in GitHub Desktop.
How to optimize SVG files with Powershell and scour

How to optimize SVG files with Powershell and scour

  1. Install Python and pip
  2. Install the Python program named scour
    pip install scour
  3. Run this program on files with the example script below.
$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