【问题标题】:error in saveGIF command in animation package动画包中的saveGIF命令出错
【发布时间】:2015-05-23 20:05:08
【问题描述】:

我第一次尝试在 R 中使用 animation 包。

我正在使用这个简单的代码:

saveGIF({
    for (i in 1:10) plot(runif(10), ylim = 0:1)
})

但 R 显示此错误(我已翻译成英文):

Executing: 
"convert" -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"
"convert" -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" is not recognized like an internal or external command,
 an executable program or batch file.
Parameter not valid - 0
an error occurred in the conversion... see Notes in ?im.convert
[1] FALSE
Warning messages:
1: running command 'C:\Windows\system32\cmd.exe /c "convert" -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) :
  '"convert" -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 '"convert" -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 4 
4: In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="animation.gif": Impossible to find the file specified

问题出在哪里?

【问题讨论】:

  • 看起来 R 找不到转换可执行文件。动画库需要安装 ImageMagick。是在你的电脑上吗?
  • 是的,我已经用默认设置安装了它
  • convert.exe 在你的 PATH 中吗?
  • 当我安装 imagemagick 时,我激活了标记:''insert un the path''。怎么判断是不是真的?
  • 您必须打开一个控制台并在其中键入 convert.exe 以查看是否可以从您计算机上的任何位置找到 convert.exe。这个 consule 在 Windows 9x 年代曾被命名为 MSDOS 控制台。我不知道情况是否仍然如此。安装 imagemagick 时是否打开了 R?如果是这种情况,您可以尝试关闭并重新打开它。

标签: r animation gif


【解决方案1】:

R 找不到转换可执行文件。您必须使用 ani.option() 指定它的完整路径和名称

ani.options(convert = 'C:\\Program Files\\ImageMagick-6.9.0-Q16\\convert.exe')

(您可能需要修改 'C:\Program Files\ImageMagick-6.9.0-Q16\')

【讨论】:

    【解决方案2】:

    在尝试所有这些修复以及thesethese 均未成功后,我使用替代软件从使用saveHTML 成功创建的 png 文件进行转换。描述了几个程序here。我是 Windows 用户,发现该站点中包含的针对 VirtualDub 的简单说明很快就完成了这项任务。

    【讨论】:

      【解决方案3】:

      我刚刚遇到了同样的问题——确保您下载的 image magick 包含转换可执行文件 (convert.exe)。我注意到当我第一次安装所有东西时没有包含它,然后在卸载并重新安装之后,我注意到有一个未选中的“包含旧工具(转换)”选项或类似的东西。确保在安装时单击该框。另外,请注意,当您以管理员身份运行 R 或 RStudio 时,它似乎工作得更好。

      【讨论】:

      • 我认为 Image Magick 的较新版本有一个 magick.exe 文件,而不是 convert.exe。当我运行 ani.options(convert = 'path\\magick.exe')
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-02
      相关资源
      最近更新 更多