Skip to content

Instantly share code, notes, and snippets.

@muety
Created January 2, 2026 15:52
Show Gist options
  • Select an option

  • Save muety/cf86f2d51f30e5d43001d510350f40f7 to your computer and use it in GitHub Desktop.

Select an option

Save muety/cf86f2d51f30e5d43001d510350f40f7 to your computer and use it in GitHub Desktop.
Scale all images inside a folder to given width and convert to WEBP format
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: $0 <width> [quality]"
echo "Example: $0 1440 95"
exit 1
fi
WIDTH=$1
QUALITY=${2:-95}
for file in *.jpg *.jpeg *.png *.gif; do
if [ -f "$file" ]; then
echo "Processing $file..."
magick "$file" -resize ${WIDTH}x -quality $QUALITY -define webp:lossless=false "${file%.*}.webp"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment