5

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

imdisplay

Kevin
  • 311
  • 5
  • 18
  • 3
    Can you test the development version? `install.packages('animation', repos = 'http://rforge.net', type = 'source')` – Yihui Xie Nov 24 '14 at 23:41

2 Answers2

2

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)
coffeinjunky
  • 11,254
  • 39
  • 57
  • Btw, this is what helped me. Anyone who can confirm that this is an issue on their systems, please comment here, as it would be good to know that this is the actual issue and not just an idiosyncracy of my system. – coffeinjunky Feb 25 '15 at 05:05
  • 2
    The error message clearly shows that the problem is the space in the path... `'C:/Program' is not recognized` – Mark Setchell Sep 10 '15 at 12:47
  • @MarkSetchell yes the program is the space, any permanent way to solve it than just using this answer? – Herman Toothrot May 20 '17 at 09:02
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"))