Skip to content

Instantly share code, notes, and snippets.

@jcontonio
Created July 25, 2024 13:48
Show Gist options
  • Save jcontonio/279d06e48804fda33e7e9f050414121f to your computer and use it in GitHub Desktop.
Save jcontonio/279d06e48804fda33e7e9f050414121f to your computer and use it in GitHub Desktop.
#!/bin/bash
PARAMS=('-m 6 -q 70 -mt -af -progress')
if [ $# -ne 0 ]; then
PARAMS=$@;
fi
cd $(pwd)
shopt -s nullglob nocaseglob extglob
for FILE in *.@(jpg|jpeg|tif|tiff|png); do
cwebp $PARAMS "$FILE" -o "${FILE%.*}".webp;
done
@jcontonio
Copy link
Author

  1. Install cwebp with brew install cwebp
  2. Create this shell script and place it in /usr/local/bin/
  3. Now you can use webp-convert-directory in any directory of images to create webp versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment