Created
February 2, 2018 00:19
-
-
Save colinrtwhite/6b27e6bb648682535a98e45b7c966d30 to your computer and use it in GitHub Desktop.
Shell scripts for recursively compressing files to PNG/WebP
This file contains hidden or 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
#!/usr/bin/env sh | |
compress() { | |
while [ "$1" ]; do | |
if [ -d "$1" ]; then | |
compress "$1"/* | |
else | |
zopflipng -m -y $1 $1 | |
fi | |
shift | |
done | |
} | |
compress * |
This file contains hidden or 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
#!/usr/bin/env sh | |
compress() { | |
while [ "$1" ]; do | |
if [ -d "$1" ]; then | |
compress "$1"/* | |
else | |
cwebp -af -mt -q 100 -lossless "$1" -o "${1%.*}.webp" | |
if [ "$1" != "${1%.*}.webp" ] && [ -f "${1%.*}.webp" ]; then | |
rm "$1" | |
fi | |
fi | |
shift | |
done | |
} | |
compress * |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment