Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error with loop=FALSE option #18

Closed
cainesap opened this issue Sep 24, 2016 · 7 comments
Closed

error with loop=FALSE option #18

cainesap opened this issue Sep 24, 2016 · 7 comments

Comments

@cainesap
Copy link

Taking the example from the README, which I can reproduce without issue, and adding what I think is the correct library (library(animate)) and options calls (ani.options(loop = FALSE)):

library(gapminder)
library(ggplot2)
library(gganimate)
library(animate)
theme_set(theme_bw())
ani.options(loop = FALSE)
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent, frame = year)) +
  geom_point() +
  scale_x_log10()
gg_animate(p)

I encounter the following error:

Executing: 
'convert' -loop FALSE -delay 100 Rplot1.png Rplot2.png Rplot3.png
    Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png
    Rplot10.png Rplot11.png Rplot12.png 'filef899fc930d.gif'
convert: invalid argument for option `-loop': FALSE @ error/convert.c/ConvertImageCommand/2024.
an error occurred in the conversion... see Notes in ?im.convert
Error in file(file, "rb") : cannot open the connection
In addition: Warning messages:
1: In normalizePath(movie.name) :
  path[1]="filef899fc930d.gif": No such file or directory
2: In file(file, "rb") :
  cannot open file '/var/folders/p8/8d4g5v_53t3glcsclzx5cc8h0000gn/T//RtmptnzNkU/gganimate/filef899fc930d.gif': No such file or directory

[Running R 3.3.1 "Bug in your hair" on Mac OS X 10.11.6]

@ottlngr
Copy link

ottlngr commented Dec 13, 2016

Is there a workaround for this issue?

@ottlngr
Copy link

ottlngr commented Jan 30, 2017

To solve this and to disable looping, one has to set loop = 1 in ani.options(), so that -loop 1 is forwarded to ImageMagick. From the ImageMagick manual:

-loop {number}:Number of times the GIF animation is to cycle though the image sequence before stopping.

So this is actually not an issue with gganimate but rather with the animation package, which provides ani.options().

@ottlngr
Copy link

ottlngr commented Jan 30, 2017

yihui/animation#90

@dgrtwo dgrtwo closed this as completed Jul 5, 2018
@pearsonca
Copy link

This issue should be resurrected - all renderers default to loop=TRUE. If I define and use

altrenderer <- gifski_renderer(loop=FALSE)
anim_save(...etc..., renderer=altrenderer)

then I can get the desired result, but the conversation here all points towards using ani.options(loop=TRUE) to manage this.

One simple approach to this would be to have loop=TRUE in the signature in anim_save and then have the default renderer construction use the value of loop.

At the very least it's a documentation issue.

@thomasp85
Copy link
Owner

This issue is related to the old API and has no bearing on the new version.

@pearsonca
Copy link

Fair enough; what is the "right" way to do it in the new API?

@thomasp85
Copy link
Owner

Do it in the renderer as you are doing already. Not all types of output can be looped so it does not make sense to have an argument in animate()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants