Created
January 2, 2026 15:52
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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