【问题标题】:creating a GIF in R error在 R 中创建 GIF 错误
【发布时间】:2017-09-07 03:01:09
【问题描述】:

我想学习如何创建一个简单的 GIF。 我找到了这段代码:

dir.create("examples")
setwd("examples")

# example 1: simple animated countdown from 10 to "GO!".
png(file="example%02d.png", width=200, height=200)
for (i in c(10:1, "G0!")){
  plot.new()
  text(.5, .5, i, cex = 6)
}
dev.off()

创建 11 个 png 图像。我想从这 11 个 11 个图像创建一个 GIF 文件,所以我使用system("convert -delay 80 *.png example_1.gif")。但我得到一个错误

> system("convert -delay 80 *.png example_1.gif")
  Invalid Parameter - 80
  Warning message:
  running command 'convert -delay 80 *.png example_1.gif' had status 4

我也看过Creating a Movie from a Series of Plots in R;但这对我也不起作用。

附:我已经安装了 ImageMagick

【问题讨论】:

  • 您是否安装了 ImageMagick 并且可以使用它(意味着它在您的 PATH 中正常驻留)?
  • 现在可以直接使用动画或者magick包了;但它也应该以另一种方式工作。我最近刚刚在我的一台机器上完成了它....
  • @RomanLuštrik 您指的是哪个 PATH ?与getwd() 一起出现的那个?
  • 允许system调用访问命令行程序的系统路径。
  • 您可能需要提供 Imagemagick convert 的完整路径。

标签: r plot gif


【解决方案1】:

尝试运行system("convert /?") 来查看问题的根源!!!

Converts a FAT volume to NTFS.

CONVERT volume /FS:NTFS [/V] [/CvtArea:filename] [/NoSecurity] [/X]


  volume      Specifies the drive letter (followed by a colon),
              mount point, or volume name.
  /FS:NTFS    Specifies that the volume will be converted to NTFS.
  /V          Specifies that Convert will be run in verbose mode.
  /CvtArea:filename
              Specifies a contiguous file in the root directory
              that will be the place holder for NTFS system files.
  /NoSecurity Specifies that the security settings on the converted
              files and directories allow access by all users.
  /X          Forces the volume to dismount first if necessary.
              All open handles to the volume will not be valid.

如果你安装了 ImageMagick 7 版本,那么这一行应该可以解决问题。

system("magick -delay 80 *.png example_1.gif")

【讨论】:

    猜你喜欢
    • 2021-11-29
    • 2021-04-10
    • 2018-08-25
    • 2019-05-10
    • 2013-08-21
    • 1970-01-01
    • 2021-12-22
    • 2013-08-21
    • 2016-02-04
    相关资源
    最近更新 更多