【发布时间】:2017-09-19 23:40:31
【问题描述】:
我想从一系列 R 绘图中制作一个 GIF 动画文件。为此,我安装了 ImageMagick 和“动画”包。
我想使用saveGIF 函数,但是当我使用该函数时,它尝试在ImageMagick 中使用convert.exe 并给出错误。看起来当前版本的 ImageMagick 使用 magick.exe 而不是 convert.exe(convert.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
【问题讨论】:
-
您是否尝试过使用
ani.options(convert = '/path/to/magick.exe')之类的方法修复可执行文件的路径? -
@Josh O'Brien 谢谢。它奏效了。