~> brew install ffmpeg
~> brew install imagemagick~> gifit ~/Desktop/pull-refresh.movpull-refresh.gif should now be in ~/Desktop
To change the gif size use the -s param.
~> gifit -s 800 ~/Desktop/pull-refresh.mov| #!/usr/bin/env bash | |
| # vim: set filetype=sh: | |
| # | |
| # Credit: https://gist.github.com/henriquea/6dac86ed357e036a1dd4 | |
| # | |
| set -e | |
| PROGRAM="${0##*/}" | |
| show_help() { | |
| cat <<_EOF | |
| Usage: | |
| $PROGRAM <MOV_FILE> [-s SCALE] | |
| _EOF | |
| } | |
| # A POSIX variable | |
| OPTIND=1 # Reset in case getopts has been used previously in the shell. | |
| TEMP_DIR=`mktemp -d -t gifit` | |
| SCALE=400 | |
| while getopts "h?s:" opt; do | |
| case "$opt" in | |
| h|\?) | |
| show_help | |
| exit 0 | |
| ;; | |
| s) SCALE=$OPTARG | |
| ;; | |
| esac | |
| done | |
| shift $((OPTIND-1)) | |
| [ "$1" = "--" ] && shift | |
| ffmpeg -i "$1" -vf scale=$SCALE:-1 -r 10 $TEMP_DIR/gif%3d.png | |
| FILENAME=${1##*/} | |
| DIR=`dirname $1` | |
| convert \ | |
| -delay 8 \ | |
| -dither none \ | |
| -coalesce \ | |
| -layers optimize \ | |
| -depth 8 \ | |
| -colors 128 \ | |
| -loop 0 \ | |
| $TEMP_DIR/gif*.png \ | |
| "$DIR/${FILENAME%.*}.gif" | |
| rm -rf $TEMP_DIR |