Skip to content

Commit

Permalink
Compress all flags by ~30% with new SVGO settings
Browse files Browse the repository at this point in the history
  • Loading branch information
HatScripts committed Dec 7, 2018
1 parent 764dd1e commit 084a827
Show file tree
Hide file tree
Showing 277 changed files with 319 additions and 275 deletions.
18 changes: 18 additions & 0 deletions compress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import shutil
from pathlib import Path
from subprocess import run

# Compress all SVG files in a directory, recursively entering subdirectories.
# This solution is necessary because SVGO lacks support for a '--recursive' option
# (https://github.com/svg/svgo/pull/712), and other workarounds are platform-dependant.

svgo = shutil.which("svgo") # https://stackoverflow.com/a/32799942/2203482

def compress(path):
# Calling "svgo -f <dir>" is much faster than calling "svgo <x.svg>" for each SVG
run([svgo, "-f", str(path), "--config=svgo.yml"])
for path in path.iterdir():
if path.is_dir():
compress(path)

compress(Path("flags"))
2 changes: 1 addition & 1 deletion flags/ad.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flags/ae.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flags/af.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flags/ag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flags/ai.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flags/al.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flags/am.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flags/ao.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flags/ar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flags/as.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flags/at.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 084a827

Please sign in to comment.