From 9c317b8c3fa7e8a2730e5ca0f27065fcb3ebeae3 Mon Sep 17 00:00:00 2001 From: Sivaramakrishnan Swaminathan Date: Tue, 13 Sep 2016 10:12:44 -0400 Subject: [PATCH] gif() now accepts an argument specifying number of times to loop Note that GIF playback might have some variability depending on the player used: https://github.com/ImageMagick/ImageMagick/issues/263 --- src/animation.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/animation.jl b/src/animation.jl index 1dd78ce7..c991ada9 100644 --- a/src/animation.jl +++ b/src/animation.jl @@ -24,7 +24,7 @@ immutable AnimatedGif filename::String end -function gif(anim::Animation, fn = (isijulia() ? "tmp.gif" : tempname()*".gif"); fps::Integer = 20) +function gif(anim::Animation, fn = (isijulia() ? "tmp.gif" : tempname()*".gif"); fps::Integer = 20, loop::Integer = 0) fn = abspath(fn) try @@ -36,7 +36,7 @@ function gif(anim::Animation, fn = (isijulia() ? "tmp.gif" : tempname()*".gif"); include(file) end # prefix = get(ENV, "MAGICK_CONFIGURE_PATH", "") - run(`convert -delay $speed -loop 0 $(joinpath(anim.dir, "*.png")) -alpha off $fn`) + run(`convert -delay $speed -loop $loop $(joinpath(anim.dir, "*.png")) -alpha off $fn`) catch err warn("""Tried to create gif using convert (ImageMagick), but got error: $err @@ -44,7 +44,7 @@ function gif(anim::Animation, fn = (isijulia() ? "tmp.gif" : tempname()*".gif"); Will try ffmpeg, but it's lower quality...)""") # low quality - run(`ffmpeg -v 0 -framerate $fps -i $(anim.dir)/%06d.png -y $fn`) + run(`ffmpeg -v 0 -framerate $fps -loop $loop -i $(anim.dir)/%06d.png -y $fn`) # run(`ffmpeg -v warning -i "fps=$fps,scale=320:-1:flags=lanczos"`) end