From 168a1fad687dd15d65dbf5c9dd5accf0f2c2e3a6 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 23 Oct 2014 11:04:41 +0200 Subject: [PATCH] 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 --- plugins/available/gif.plugin.bash | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 plugins/available/gif.plugin.bash diff --git a/plugins/available/gif.plugin.bash b/plugins/available/gif.plugin.bash new file mode 100644 index 00000000..596111cd --- /dev/null +++ b/plugins/available/gif.plugin.bash @@ -0,0 +1,34 @@ +cite about-plugin +about-plugin 'gif helper functions' + +# From https://gist.github.com/SlexAxton/4989674#comment-1199058 +# Requirements (Mac OS X using Homebrew): brew install ffmpeg gifsicle imagemagick +function gifify { + about 'Converts a .mov file into an into an animated GIF.' + group 'gif' + param '1: MOV file name' + param '2: max width in pixels (optional)' + example '$ gifify foo.mov' + example '$ gifify foo.mov 600' + + if [ -z "$1" ]; then + echo "$(tput setaf 1)No input file given. Example: gifify example.mov [max width (pixels)]$(tput sgr 0)" + return 1 + fi + + output_file="${1%.*}.gif" + + echo "$(tput setaf 2)Creating $output_file...$(tput sgr 0)" + + if [ ! -z "$2" ]; then + maxsize="-vf scale=$2:-1" + else + maxsize="" + fi + + ffmpeg -loglevel panic -i $1 $maxsize -r 10 -vcodec png gifify-tmp-%05d.png + convert +dither -layers Optimize gifify-tmp-*.png GIF:- | gifsicle --no-warnings --colors 256 --delay=10 --loop --optimize=3 --multifile - > $output_file + rm gifify-tmp-*.png + + echo "$(tput setaf 2)Done.$(tput sgr 0)" +}