Skip to content

Instantly share code, notes, and snippets.

@anurag-roy
Forked from tabrindle/webp-convert-directory.sh
Last active September 8, 2021 21:18
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 anurag-roy/86f312125bf76f0b93c10492c162b26f to your computer and use it in GitHub Desktop.
Save anurag-roy/86f312125bf76f0b93c10492c162b26f to your computer and use it in GitHub Desktop.
Convert all files in directory to webp, with default params, or standard cwebp params passed from command
#!/bin/bash
PARAMS=('-m 6 -q 70 -mt -af -progress')
if [ $# -ne 0 ]; then
PARAMS=$@;
fi
cd $(pwd)
shopt -s globstar nullglob nocaseglob extglob
for FILE in $PWD/**/*.@(jpg|jpeg|tif|tiff|png); do
cwebp $PARAMS "$FILE" -o "${FILE%.*}".webp;
done
@anurag-roy
Copy link
Author

To fix problems with globstar(especially on MacOS), use this gist.

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