Skip to content

Instantly share code, notes, and snippets.

@sidisinsane
Created April 4, 2020 10:19
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 sidisinsane/552f56b39541f2f3e3bd78c2168957e3 to your computer and use it in GitHub Desktop.
Save sidisinsane/552f56b39541f2f3e3bd78c2168957e3 to your computer and use it in GitHub Desktop.
Create WebP Images
#!/usr/bin/env bash
quality=80
shopt -s nullglob nocaseglob extglob
for file in src/assets/img/**/*.@(jpg|jpeg|png); do
if [ -f "${file%.*}.webp" ]; then
echo "${file%.*}.webp exists"
else
cwebp -q $quality "$file" -o "${file%.*}.webp"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment