Skip to content

Instantly share code, notes, and snippets.

@DanielOberlechner
Created June 18, 2022 13:54
Show Gist options
  • Save DanielOberlechner/abff9d1b1f18b7a806e8b0ed3674816b to your computer and use it in GitHub Desktop.
Save DanielOberlechner/abff9d1b1f18b7a806e8b0ed3674816b to your computer and use it in GitHub Desktop.
webp convert all files in current folder with best compression
#!/bin/bash
# -m maximize compression power
# -mt multithreading
# -q quality
# -af optimize with auto filter
# -size enter the wanted compression file size in bytes 250000 are 250 kiloBytes
PARAMS=('-m 6 -q 50 -mt -af -progress')
if [ $# -ne 0 ]; then
PARAMS=$@;
fi
cd $(pwd)
shopt -s nullglob nocaseglob extglob
for FILE in *.@(jpg|jpeg|tif|tiff|png|svg); do
cwebp $PARAMS "$FILE" -o "${FILE%.*}".webp;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment