I am trying to make a GIF-animation in R. I have an array of matrices which i wish to convert into a GIF animation. My strategy is inspired from this example:
http://ryouready.wordpress.com/2010/11/21/animate-gif-images-in-r-imagemagick/
where the following code produces 11 PNG-Pictures with the "png"-function in R. Next it calls for the external ImageMagick-program "convert" to compile the GIF animation.
dir.create("examples") setwd("examples") # Animated countdown from 10 to "GO!". png(file="example%02d.png", width=200, height=200) for (i in c(10:1, "G0!")){ plot.new() text(.5, .5, i, cex = 6) } dev.off() # convert the .png files to one .gif file using ImageMagick. system("convert -delay 80 *.png example_1.gif") #shell("convert -delay 80 *.png example_1.gif") The problem is that R doesn't seem to finde the exe-file "convert" which is a part of ImageMagick and installed on the C-drive (C:\Program Files\ImageMagick-6.8.5-Q16). In the comments to the website i am linking to earlier, it is suggested for Windows users to use "shell" instead of "system" to run external programs but none of the two work. The error message is
Invalid parameter - 80 Warning message: running command 'convert -delay 80 *.png example_1.gif' had status 4 I've tried to change the Windows PATH enviroment variable in the systems properties, as suggested in this answer, but the PATH-variable was allready corectlly defined on my system. I also tried specifying the whole string of the convert.exe file, but also without luck...
How can i get ImageMagick to run through R?
Specs: Windows 7 Servicepack 1, R 3.0.0
Thanks in advance...
convert... What error message do you get when you use the full path? One possibility is that you have anotherconvertprogram in yourPATH. In case you added the directory at the end of thePATHenvironment variable, try putting it at the beginning instead.system("where convert", intern = TRUE)give you?convertvariable is the ImageMagick filepath, just checked again. When i run the codesystem("C:/Program Files/ImageMagick-6.8.5-Q16/convert -delay 80 *.png example_1.gif")apparently nothing happens. When i run ´shell("C:/Program Files/ImageMagick-6.8.5-Q16/convert -delay 80 *.png example_1.gif")´ i get the error message:'C:/Program' was not recognized as an internal or external command, program or batch file.and then a whole series of R-errors.> system("where convert", intern = TRUE) [1] "C:\\Program Files\\ImageMagick-6.8.5-Q16\\convert.exe" [2] "C:\\Windows\\System32\\convert.exe"Thank you very much for you help... it's greatly apprieciated.system('"C:\\Program Files\\ImageMagick-6.8.5-Q16\\convert.exe" -delay 80 *.png example_1.gif', intern = TRUE)then.