Skip to content

Commit e4bdad6

Browse files
committed
Added the gifify function.
This allows to convert a .mov file into an animated GIF file. Based on these resources: * https://gist.github.com/SlexAxton/4989674 * https://gist.github.com/paulirish/b6cf161009af0708315c
1 parent 8ea7e30 commit e4bdad6

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

plugins/available/gif.plugin.bash

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
}

0 commit comments

Comments
 (0)