【问题标题】:Error saving gif video with R animation library and Imagemagick使用 R 动画库和 Imagemagick 保存 gif 视频时出错
【发布时间】:2015-01-12 00:48:17
【问题描述】:

我正在尝试使用 Windows 7 创建一个简单的 .gif 视频。我安装了 ImageMagick,它似乎可以自行运行。这是我尝试运行的以下代码和相应的错误消息。当我运行代码时,ImageMagik 程序打开,它看起来像第一次运行的数据被绘制(见下图)。我怀疑问题是 Windows 和 Unix 命令之间的差异?也许我需要在 ani.options 中添加更多内容?任何帮助或建议将不胜感激。谢谢。

添加所需的库

图书馆(动画)

确保 convert 位于我保存数据的位置

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 视频

保存GIF({ + 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 "动画.gif" 'C:/Program' 未被识别为内部或外部命令, 可运行的程序或批处理文件。 输出:animation.gif [1] 对 警告信息: 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(convert) 中: '"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

【问题讨论】:

  • 可以测试开发版吗? install.packages('animation', repos = 'http://rforge.net', type = 'source')

标签: r imagemagick gif


【解决方案1】:

我遇到了同样的问题。强加一个短文件路径为我解决了这个错误。

 path.to.convert <- paste0(shortPathName(
                    "C:\\Program Files\\ImageMagick-6.9.0-Q16\\"), "convert.exe")
 ani.options(convert=path.to.convert)

【讨论】:

  • 顺便说一句,这对我有帮助。任何可以确认这是他们系统上的问题的人,请在此处发表评论,因为很高兴知道这是实际问题,而不仅仅是我系统的特殊性。
  • 报错信息清楚地表明问题出在路径中的空格...'C:/Program' is not recognized
  • @MarkSetchell 是的,程序就是空间,除了使用这个答案之外,还有什么永久的方法可以解决它?
【解决方案2】:

我遇到了同样的问题。短路径技巧做到了!但有了 Image Magick 7.x 版,不再有“convert.exe”。以下作品:

ani.options(convert=shortPathName("C:\\Program Files\\ImageMagick\\magick.exe"))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-31
    • 1970-01-01
    • 2014-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-28
    • 1970-01-01
    相关资源
    最近更新 更多