R {animation}包[saveGIF] - 想用magick代替转换

时间:2017-04-23 07:42:40

标签: r animation

我想从一系列R图中制作一个GIF动画文件。我安装了ImageMagick和“animation”包来执行此操作。

我想使用saveGIF函数,但是当我使用该函数时,它会尝试在ImageMagick中使用convert.exe并给出错误。看起来ImageMagick的当前版本使用magick.exe而不是convert.execonvert.exe不存在)。

我可以使用magick.exe直接从ImageMagick制作GIF动画而不使用动画包。但是如果我可以使saveGIF使用magick.exe代替convert.exe,对我来说会更方便。我想知道怎么做。

安装仍然使用convert.exe的旧版ImageMagick可以解决问题,但这不是我要找的答案。

更新

我试过Josh O'Brien提出的ani.options。以下是我得到的。不确定问题是什么......

> ani.options(convert = 'C:/Program Files/ImageMagick-7.0.5-Q16/magick.exe')
> 
> saveGIF(
+ for(i in 1:10){
+ plot(i,1,xlim=c(0,11))
+ }
+ )
Executing: 
"C:/Program Files/ImageMagick-7.0.5-Q16/magick.exe -loop 0 -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png
    Rplot8.png Rplot9.png Rplot10.png "animation.gif""
'C:/Program' is not recognized as an internal or external command,
operable program or batch file.
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-7.0.5-Q16/magick.exe -loop 0  -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "animation.gif""' had status 1 
2: In cmd.fun(convert) :
  '"C:/Program Files/ImageMagick-7.0.5-Q16/magick.exe -loop 0  -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "animation.gif""' execution failed with error code 1
3: running command '"C:/Program Files/ImageMagick-7.0.5-Q16/magick.exe -loop 0  -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "animation.gif""' had status 127 

1 个答案:

答案 0 :(得分:4)

Josh O'Brien的回答奏效了。 “程序文件”必须更改为“PROGRA~1”。

ani.options(convert = 'C:/PROGRA~1/ImageMagick-7.0.5-Q16/magick.exe')

saveGIF(
for(i in 1:10){
plot(i,1,xlim=c(0,11))
}
)
相关问题