使用动画包R时出错

时间:2015-03-09 13:01:57

标签: r imagemagick

试图在R中运行以下代码:

ani.options(
   convert = shQuote("C:/Program Files/ImageMagick-6.9.0-Q16/convert.exe")
)
 saveGIF(
{
  for (i in 1:10) plot(runif(10), ylim = 0:1)
},
 movie.name = "test.gif", 
interval = 0.2, 
ani.width = 300, 
ani.height = 300,
outdir = getwd()
)

获取错误消息:

Executing: 
"\"C:/Program Files/ImageMagick-6.9.0-Q16/convert.exe\"" -loop 0 -delay 20     Rplot1.png Rplot2.png Rplot3.png
Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "test.gif"
The filename, directory name, or volume label syntax is incorrect.
an error occurred in the conversion... see Notes in ?im.convert
[1] FALSE
Warning messages:
1: running command 'C:\Windows\system32\cmd.exe /c "\"C:/Program     Files/ImageMagick-6.9.0-Q16/convert.exe\"" --version' had status 1 
2: running command 'C:\Windows\system32\cmd.exe /c "\"C:/Program Files/ImageMagick-6.9.0-Q16/convert.exe\"" -loop 0  -delay 20 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "test.gif"' had status 1 
3: In cmd.fun(convert) :
  '"\"C:/Program Files/ImageMagick-6.9.0-Q16/convert.exe\"" -loop 0  -delay 20 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "test.gif"' execution failed with error code 1
4: running command '"\"C:/Program Files/ImageMagick-6.9.0-Q16/convert.exe\"" -loop 0  -delay 20 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png     Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "test.gif"' had status 127 

有人可以指出我的错误。

1 个答案:

答案 0 :(得分:2)

我有同样的问题,似乎是由于转换的路径。 如果我输入:

  

ani.options(convert = shQuote(' C:/ Program Files / ImageMagick-6.8.7-Q16 / convert.exe'))

然后检查路径

  

ani.options("转换&#34)   [1]" \" C:/ Program Files / ImageMagick-6.8.7-Q16 / convert.exe \""

但是,如果我这样做:

  

ani.options(convert =' C:/ Program Files / ImageMagick-6.8.7-Q16 / convert.exe')   ani.options("转换&#34)   [1]" C:/ Program Files / ImageMagick-6.8.7-Q16 / convert.exe"

这是正确的路径和saveGIF的工作......奇怪的事情......