yihui / animation

A gallery of animations in statistics and utilities to create animations

Home Page:https://yihui.org/animation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use path.expand with saveGIF output?

MichaelChirico opened this issue · comments

I'm running the latest CRAN version (2.4) and had the following issue:

saveGIF(sapply(1:10, function(x) plot(1:x, 1:x)), "~/my.gif")

Executing:
'convert' -loop 0 -delay 100 Rplot1.png
Rplot2.png Rplot3.png Rplot4.png Rplot5.png
Rplot6.png Rplot7.png Rplot8.png Rplot9.png
Rplot10.png '/my.gif'
convert.im6: unable to open image `
/my.gif': No such file or directory @ error/blob.c/OpenBlob/2641.
an error occurred in the conversion... see Notes in ?im.convert
# [1] FALSE
Warning message:
In normalizePath(movie.name) :
path[1]="/home/michael/my.gif": No such file or directory

Running debugonce on saveGIF shows that it's im.convert that's causing the issue (then the warning message is coming from saveGIF itself afer im.convert fails.

From what I can tell, this is because im.convert just uses shQuote on output, and convert in the shell doesn't understand the tilde.

I've fixed this sort of problem before using path.expand, so the command would simply become shQuote(path.expand(output)).

Any reason not to implement this?

Noticed while writing this that it appears to have been fixed in the devel version here; I submitted this since I searched around the issues page and couldn't find anything about it, hopefully this will help someone else in my position.

Am curious to hear the rationale behind not just using path.expand, however.

Hi Michael,
Sorry for the late reply and thanks for your suggestion.
Using path.expand() is a good choice.
I will implement it ASAP and fix the bug below.

> saveGIF(sapply(1:10, function(x) plot(1:x, 1:x)), "~/my.gif")
Executing: 
convert -loop 0 -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png
    Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png 'my.gif'
Output at: /root/my.gif
gvfs-open: ~/my.gif: error opening location: Error when getting information for file '/root/~/my.gif': No such file or directory