Kevin
Kevin

Reputation: 311

Error saving gif video with R animation library and Imagemagick

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

Upvotes: 5

Views: 1491

Answers (2)

user8207388
user8207388

Reputation: 21

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"))

Upvotes: 2

coffeinjunky
coffeinjunky

Reputation: 11514

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)

Upvotes: 2

Related Questions