我想根据一系列R绘图制作GIF动画文件。我安装了ImageMagick和“动画”程序包来执行此操作。
我想使用saveGIF函数,但是当我使用函数时,它尝试convert.exe在ImageMagick中使用并给出错误。看起来当前版本的ImageMagick使用magick.exe而不是convert.exe(convert.exe不存在)。
我可以直接使用ImageMagick制作GIF动画,magick.exe而无需使用动画包。但是如果我可以使用saveGIF magick.exe而不是,对我来说更方便convert.exe。我想知道怎么做。
安装仍然使用的较旧版本的ImageMagick convert.exe将解决问题,但这不是我要的答案。
我尝试ani.options了乔希·奥布赖恩(Josh O'Brien)的建议。以下是我得到的。不确定是什么问题...
> 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
Run Code Online (Sandbox Code Playgroud)
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))
}
)
Run Code Online (Sandbox Code Playgroud)