Skip to content

Instantly share code, notes, and snippets.

@long-blade
Last active January 14, 2022 19:57
Show Gist options
  • Save long-blade/2f6bd88f59e4fb972fb889216f74654d to your computer and use it in GitHub Desktop.
Save long-blade/2f6bd88f59e4fb972fb889216f74654d to your computer and use it in GitHub Desktop.
[Image resizer] Resize images for a directory of image files. #bash, #bashscripting
#! usr/bin/bash
## execute: bash resize.sh /path/to/files
for f in "$1"/*.{jpg,png}; do
[ -f "$f" ] || continue #skip in case f is not a regular file.
base=$(basename "$f")
echo "Converting $1/${base%.*}.${base##*.}"
convert "$f" -resize 1920x1322 -gravity center -background white -extent 1600x1102 "$1/${base%.*}.${base##*.}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment