4

I'm having trouble with the SaveGIF function in library (animation). The function gives me this error:

Error in cmd.fun(sprintf("%s --version", convert), intern = TRUE, ignore.stdout = !interactive(), :
unused argument(s) (ignore.stdout = !interactive())
I cannot find ImageMagick with convert = 'convert'
NULL
Warning message:
In im.convert(img.files, output = movie.name, convert = convert, :
Please install ImageMagick first or put its bin path into the system PATH variable

What confuses me is that I do have convert on my system, so I'd expect SaveGIF to be able to find it without any trouble:

me@my-laptop:~$ convert --version

Version: ImageMagick 6.5.7-8 2010-12-02 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009

How do I add convert's bin path to the system PATH variable?

Edit: I'm using Ubuntu, not Windows.

Community
  • 1
  • 1
Adrian
  • 3,138
  • 2
  • 28
  • 39
  • This question is quite old, but I want to add a remark for people who look in the futue. I had the same issue on a Windows machine despite the path being set correctly to include the directory of Imagemagick. What worked for me was this one, but it would be good if people with the same issue could confirm that this solution workes for them as well: http://stackoverflow.com/questions/26933194/error-saving-gif-video-with-r-animation-library-and-imagemagick/28710980#28710980 – coffeinjunky Feb 25 '15 at 16:13

4 Answers4

2

You probably did not edit your PATH variable. On Windows 7 (but will probably work on earlier versions to) go to:

start menu

Right click computer -> properties

Advanced System Settings

Environment Variables

Then under "System variables" (the lower pane) find the variable "path", select it and click edit.

You are interested in the content of Variable value (maybe copy it to a text editor to read it better). It should contain the link to imagemagick in it, seperated by semicolons from other variables. For me the path to imagemagick is:

C:\Program Files\ImageMagick-6.6.7-Q16

Make sure you only add it, not change anything else to the path variable. Add it with a semicolon.

Sacha Epskamp
  • 46,463
  • 20
  • 113
  • 131
2

Usually we do not need to manually set the PATH variable under Linux. I'm using Ubuntu as well, but I cannot reproduce your error. What's your R version?

> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] animation_2.0-4    

As far as I can see, the error comes from the function system() instead of not being able to find convert. The argument ignore.stdout came in R 2.12.1, so you must be using a lower version of R. The current version is 2.13.0, and I recommend you to upgrade to the latest version. See http://cran.r-project.org/bin/linux/ubuntu/ for how to keep R updated with CRAN.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
  • I'm seeing this error on OS X, R 3.1.1 and confirmed I have convert as OP did. Any suggestions? – Max Ghenis Oct 22 '14 at 10:41
  • @MaxGhenis The OP was using Ubuntu, and you did not tell us your OS X version. If it is Yosemite, I will not be surprised: http://stackoverflow.com/q/26491934/559676 – Yihui Xie Oct 22 '14 at 15:48
1

You can find where your convert function lives with system("which convert", intern=TRUE) and then you (may be able to) add that to your PATH variable with

Sys.setenv(PATH=...)

Greg
  • 11,564
  • 5
  • 41
  • 27
  • I tried that, but no success; system("which convert", intern=TRUE) returns "/usr/bin/convert", I ran Sys.setenv(PATH="/usr/bin/convert") and eg saveGIF(brownian.motion()) still gives the same "Please install ImageMagick first or put its bin path into the system PATH variable" error. – Adrian May 27 '11 at 00:05
  • I think it would be Sys.setenv(PATH="/usr/bin"). After running that, try Sys.getenv()$PATH and see what it returns. – Greg May 27 '11 at 00:40
0

After attempting all of these fixes as well as these and these to no success, I used alternative software to make the conversion from the png files that were successfully created with saveHTML. Several programs are described here. I am a Windows user and found the simple instructions contained in that site for VirtualDub quickly accomplished this task.

Community
  • 1
  • 1
Luke Macaulay
  • 393
  • 5
  • 14