Skip to content

Instantly share code, notes, and snippets.

@Zemnmez
Created April 4, 2017 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zemnmez/9dd9a11f51454f15d631e5491f182cc2 to your computer and use it in GitHub Desktop.
Save Zemnmez/9dd9a11f51454f15d631e5491f182cc2 to your computer and use it in GitHub Desktop.
resizes a target image (can be gif) to given formats usage ./sizes.sh in.gif 10x20 20x40
#!/bin/bash
set -e
originalSize="$(identify -format "%wx%h\n" $1|head -1)"
tmp="${1%%.*}-temp.${1#*.}"
convert $1 -coalesce -layers Optimize "$tmp"
for SZ in "${@:2}"; do
convert -size "$originalSize" "$tmp" -resize "$SZ" \
"${1%%.*}-$SZ.${1#*.}"
done
rm "$tmp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment