Error saving gif video with R animation library and Imagemagick

烂漫一生 提交于 2020-01-11 08:56:16

问题


I am trying to create a simple .gif video using Windows 7. I installed ImageMagick and it seems to be working by itself. Here is the following code I tried to run and the corresponding error message. When I run the code the ImageMagik program opens up and it looks like the data for the first run is plotted (see image below). I suspect the problem is differences between windows and Unix commands? Perhaps I need to add more to the ani.options? Any help or suggestions would be greatly appreciated. Thank you.

Add libraries needed

library(animation)

Make sure convert is at my location of where the data is saved

ani.options(convert = 'C:/Program Files/ImageMagick-6.8.9-Q16/convert.exe') ani.options("convert")#check to see if short hand notation works

[1] "C:/Program Files/ImageMagick-6.8.9-Q16/convert.exe"

Create a .gif video of the graph

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

Executing: "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' is not recognized as an internal or external command, operable program or batch file. Output at: animation.gif [1] TRUE Warning messages: 1: running command '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"' had status 1 2: In 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"' execution failed with error code 1


回答1:


I encountered the same problem. Imposing a short file path solved the error for me.

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



回答2:


I had the same problem. The short path trick does it! But With Image Magick Version 7.x there no longer is a "convert.exe". The following works:

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


来源:https://stackoverflow.com/questions/26933194/error-saving-gif-video-with-r-animation-library-and-imagemagick

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!