Skip to content

Instantly share code, notes, and snippets.

@sebstr1
Created December 12, 2018 13:04
Show Gist options
  • Save sebstr1/61d58eb7914cec40ddbd7dc547945064 to your computer and use it in GitHub Desktop.
Save sebstr1/61d58eb7914cec40ddbd7dc547945064 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Batch Convert all images in folder to webp.
# Create .sh file, paste this into the file, make it executable and run it; "./webp_batch.sh /path/to/folder/"
PATH=/usr/local/bin:/usr/bin:/bin
PARAMS=('cwebp -q 75 -alpha_q 10') # -alpha_q 10 is for images with transparent background
cd $1 || exit 1
shopt -s nullglob nocaseglob extglob
for FILE in *.@(jpg|jpeg|tif|tiff|png); do
cwebp $PARAMS "$FILE" -o "${FILE%.*}".webp;
done
echo "Conversion complete for folder " $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment