Skip to content

Instantly share code, notes, and snippets.

@haochi
Last active December 6, 2016 15:48
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 haochi/8f2227303ce30956f403684d947df23c to your computer and use it in GitHub Desktop.
Save haochi/8f2227303ce30956f403684d947df23c to your computer and use it in GitHub Desktop.
Turn an image into a rotating gif
#!/usr/bin/env bash
# usage: ./rotate in_file_name out_file_name
in_file="$1"
out_file="$2"
turns=12
degree=$((360 / $turns));
rotated=()
for (( i=0; i<$turns; i++ )); do
tempfile=$(mktemp)
rotated+=("$tempfile")
rotation=$(($degree * $i))
convert -background white "$in_file" -distort SRT -$rotation "$tempfile"
done
convert -delay 10 -loop 0 "${rotated[@]}" "$out_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment