Skip to content

Instantly share code, notes, and snippets.

@reatlat
Created December 6, 2018 21:46
Show Gist options
  • Select an option

  • Save reatlat/6476d9e0c817e4b3cabbb2036ea91a90 to your computer and use it in GitHub Desktop.

Select an option

Save reatlat/6476d9e0c817e4b3cabbb2036ea91a90 to your computer and use it in GitHub Desktop.
#!/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