Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error saving gif video with R animation library and Imagemagick

Tags:

r

gif

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

like image 604
Kevin Avatar asked Sep 29 '22 10:09

Kevin


2 Answers

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)
like image 167
coffeinjunky Avatar answered Oct 02 '22 16:10

coffeinjunky


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"))
like image 34
user8207388 Avatar answered Oct 02 '22 15:10

user8207388