Created
December 6, 2018 21:46
-
-
Save reatlat/6476d9e0c817e4b3cabbb2036ea91a90 to your computer and use it in GitHub Desktop.
Rescale several images to same size. https://unix.stackexchange.com/questions/122586/how-to-rescale-several-images-to-same-size
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 | |
| images=$(identify -format '%f\n' * 2>/dev/null) | |
| IFS=$'\n' | |
| set -e | |
| max_dims=$( | |
| identify -format '%w %h\n' $images 2>/dev/null | | |
| awk '($1>w){w=$1} ($2>h){h=$2} END{print w"x"h}' | |
| ) | |
| orig_dir=originals_$(date +%Y-%m-%d_%T) | |
| mkdir "$orig_dir" | |
| mv -- $images "$orig_dir" | |
| cd "$orig_dir" | |
| set +e | |
| for image in $images; do | |
| convert -- "$image" -gravity Center -extent "$max_dims" "../$image" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment