我正在尝试使用Windows 7创建一个简单的.gif视频.我安装了ImageMagick,它似乎独立工作.这是我尝试运行的以下代码和相应的错误消息.当我运行代码时,ImageMagik程序打开,看起来第一次运行的数据被绘制(见下图).我怀疑问题是Windows和Unix命令之间的差异?也许我需要在ani.options中添加更多内容?任何帮助或建议将不胜感激.谢谢.
添加所需的库
库(动画)
确保转换位于我保存数据的位置
ani.options(convert ='C:/ Program Files/ImageMagick-6.8.9-Q16/convert.exe')ani.options("convert")#检查短手记号是否有效
[1]"C:/ Program Files/ImageMagick-6.8.9-Q16/convert.exe"
创建图表的.gif视频
saveGIF({+ for(i in 1:10)plot(runif(10),ylim = 0:1)+})
执行:"C:/ Program Files/ImageMagick-6.8.9-Q16/convert.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'未被识别为内部或外部命令,可运行程序或批处理文件.输出于:animation.gif [1] TRUE警告消息:1:运行命令'C:\ Windows\system32\cmd.exe/c"C:/ Program Files/ImageMagick-6.8.9-Q16/convert.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"'的状态为1 2:在cmd.fun (转换):'"C:/ Program Files/ImageMagick-6.8.9-Q16/convert.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"执行失败,错误代码为1
我遇到了同样的问题。强加一个短文件路径解决了我的错误。
path.to.convert <- paste0(shortPathName(
"C:\\Program Files\\ImageMagick-6.9.0-Q16\\"), "convert.exe")
ani.options(convert=path.to.convert)
Run Code Online (Sandbox Code Playgroud)