Skip to content

Instantly share code, notes, and snippets.

@thetwopct
Created September 29, 2025 06:46
Show Gist options
  • Select an option

  • Save thetwopct/84d2f153414e26e4be35a9197bc97d09 to your computer and use it in GitHub Desktop.

Select an option

Save thetwopct/84d2f153414e26e4be35a9197bc97d09 to your computer and use it in GitHub Desktop.
Convert images in recursive directories to webp
find . -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -print0 |
xargs -0 -n1 -P"$(sysctl -n hw.ncpu)" -I{} \
sh -c 'f="$1"; out="${f%.*}.webp"; [ -f "$out" ] || cwebp -quiet -q 90 -metadata icc,exif,xmp "$f" -o "$out"' _ {}
# change names if you want to add, ignore, skip some file names
# change 90 to 82 or another number if you want the images more lossy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment