R:动画包的新错误:Imagemagick 中不再有 convert.exe

R: new error with animation package: convert.exe no longer in Imagemagick

从动画的 2.5 版开始,在 Windows 7 上调用 ImageMagick 实用程序 convert.exe 的路径问题似乎仍然存在。这可以通过向 ani.option 添加转换选项来解决。但是,现在新版本 7(.0.6.Q16) 不包含 covert.exe(动态和静态构建)。 ImageMagick 中 exe 文件的 DOS 列表给出

Directory of C:\Program Files\ImageMagick-7.0.6-Q16

11/Jun/17  12:10 PM           828,416 dcraw.exe
11/Jun/17  12:08 PM        33,351,680 ffmpeg.exe
11/Jun/17  12:08 PM           113,664 hp2xx.exe
11/Jun/17  12:14 PM        16,340,480 imdisplay.exe
11/Jun/17  12:14 PM        16,471,552 magick.exe
20/Jun/17  11:22 AM         1,202,385 unins000.exe
6 File(s)     68,308,177 bytes

Directory of C:\Program Files\ImageMagick-7.0.6-Q16\uninstall

11/Jun/17  12:07 PM           122,279 PathTool.exe
1 File(s)        122,279 bytes

Total Files Listed:
7 File(s)     68,430,456 bytes

因此,用于创建具有以下法线的动画 GIF 的 R 命令失败并出现错误

Executing: 
""C:\Program Files\ImageMagick-7.0.6-Q16\convert.exe" -loop 0 -delay 12 Rplot1.png Rplot2.png Rplot3.png
    Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png Rplot11.png Rplot12.png
    Rplot13.png Rplot14.png Rplot15.png Rplot16.png Rplot17.png Rplot18.png Rplot19.png Rplot20.png
    "Normals1_Ani.gif""
'"C:\Program Files\ImageMagick-7.0.6-Q16\convert.exe"' 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

im.convert帮助中没有提到可能遗漏convert.exe。

我运行的R命令是

 library(animation)
 donorm = function(k){
   require(ggplot2)
   Ns = matrix(0, 1000, k)
   X = matrix(0, 1000, k)
   for (i in 1:k){
     X[, i] = sort(rnorm(1000, mean = ifelse(i<11,0,2), sd = 0.5*ifelse(i<11,sqrt(i), sqrt(i -10))))
     Ns[, i] = dnorm(X[,i], mean = ifelse(i<11,0, 2), sd = 0.5*ifelse(i<11,sqrt(i), sqrt(i -10)))
   }
   mx = c(min(X), max(X))
   my = max(Ns)
   dat = data.frame(x = rep(0, 1000), y = rep(0, 1000))
   for (i in 1:k){
     dat$x = X[,i]; dat$y = Ns[,i]
     pl = ggplot2::ggplot(dat, aes(x = x, y= y)) + geom_line(color = i%%5 + 1, size = 1.5) + 
     coord_cartesian(xlim = mx, ylim = c(0, my)) +
     annotate("text", x = mx[1]+0.25, y = my[2]-0.25, label = 
                paste("mean = ", round(ifelse(i<11,0,2),1),"//st.dev = ", round(0.5*ifelse(i<11,sqrt(i), sqrt(i -10)), 1))) +
       theme_bw()
     print(pl)
   }
 }

## this is suggested solution for calling convert.exe but it fails on my system
# path_to_convert <- paste0(shortPathName("C:\Program Files\ImageMagick-7.0.6-Q16\"), "convert.exe")

## this would work were the exe there
path_to_convert = "\"C:\Program Files\ImageMagick-7.0.6-Q16\convert.exe\""

animation::ani.options(interval = 0.12, ani.width = 480, ani.height = 320, convert=path_to_convert)
animation::saveGIF(donorm(20), movie.name = paste0("Normals",1,"_Ani.gif"))

命令正确,预期图像(使用我的笔记本电脑生成,LyX 中嵌入了 ImageMagick - 不确定 ImageMagick 的哪个版本,但 convert.exe 是版本 6)如图所示。

我无法安装 Imagemagick 版本 6,因为 website, the change log 上只有版本 7 的二进制文件,没有提到删除 convert.exe 实用程序。我不想安装 LyX。

有人可以提出解决方案吗?

更新解决方案

如@fnw42 的回答中所述,在 ImageMagick 版本 7 中

The "magick" command is the new primary command of the Shell API, replacing the old "convert" command.

因此要使用 saveGif,必须在转换命令选项中反映这一变化。例如,在上面的代码中,需要将 convert.exe 替换为 magick.exe,如

path_to_convert = "\"C:\Program Files\ImageMagick-7.0.6-Q16\magick.exe\""

也可以调用旧的转换实用程序 'magick convert'。现在已弃用一些选项,并添加了一些新选项。查看 porting explanation 上的详细信息。

我还发现旧的 Imagemagick 版本在 sourceforge 上可用。

在 Imagemagck 7 中,您必须将 convert (convert.exe) 替换为 magick (magick.exe,除非您从 Widows ImageMagick 安装程序安装旧版组件。那么 convert.exe 将是实际上 运行ning IM 6。到 运行 IM 7,使用 magick。见 http://imagemagick.org/script/porting.php#cli

抱歉,我不知道 R.