Skip to content

Instantly share code, notes, and snippets.

@schellenbergk
Last active February 23, 2019 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schellenbergk/870d263ca4a7018d8fe36f8e787b1a25 to your computer and use it in GitHub Desktop.
Save schellenbergk/870d263ca4a7018d8fe36f8e787b1a25 to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage examples:
# toWebP.sh "*.png" # convert all png's in current directory
# toWebP.sh "icon-*.jpg" # convert all jpg's that start with "icon-"
if [ $# -eq 0 -o -z "$1" ]; then
echo "No file pattern supplied";
exit 1;
fi
for file in $1
do
echo "Converting $file";
cwebp -q 80 "$file" -o "${file%.*}.webp"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment