Last active
December 6, 2016 15:48
-
-
Save haochi/8f2227303ce30956f403684d947df23c to your computer and use it in GitHub Desktop.
Turn an image into a rotating gif
This file contains 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
#!/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