File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ cite about-plugin
2+ about-plugin ' gif helper functions'
3+
4+ # From https://gist.github.com/SlexAxton/4989674#comment-1199058
5+ # Requirements (Mac OS X using Homebrew): brew install ffmpeg gifsicle imagemagick
6+ function gifify {
7+ about ' Converts a .mov file into an into an animated GIF.'
8+ group ' gif'
9+ param ' 1: MOV file name'
10+ param ' 2: max width in pixels (optional)'
11+ example ' $ gifify foo.mov'
12+ example ' $ gifify foo.mov 600'
13+
14+ if [ -z " $1 " ]; then
15+ echo " $( tput setaf 1) No input file given. Example: gifify example.mov [max width (pixels)]$( tput sgr 0) "
16+ return 1
17+ fi
18+
19+ output_file=" ${1% .* } .gif"
20+
21+ echo " $( tput setaf 2) Creating $output_file ...$( tput sgr 0) "
22+
23+ if [ ! -z " $2 " ]; then
24+ maxsize=" -vf scale=$2 :-1"
25+ else
26+ maxsize=" "
27+ fi
28+
29+ ffmpeg -loglevel panic -i $1 $maxsize -r 10 -vcodec png gifify-tmp-%05d.png
30+ convert +dither -layers Optimize gifify-tmp-* .png GIF:- | gifsicle --no-warnings --colors 256 --delay=10 --loop --optimize=3 --multifile - > $output_file
31+ rm gifify-tmp-* .png
32+
33+ echo " $( tput setaf 2) Done.$( tput sgr 0) "
34+ }
You can’t perform that action at this time.
0 commit comments