Error running ImageMagick from R: Invalid parameter Error running ImageMagick from R: Invalid parameter shell shell

Error running ImageMagick from R: Invalid parameter


On Windows, there are several convert.exe commands, all of which are in the PATH. So you must specify the path to the right convert.exe executable. In my case, I had it in the LyX folder (however, you will find it in the ImageMagick installation too).Be careful with the quotes, the backslashes and the spacing if you are pasting. E.g. from within R:

system('"C:\\Program Files (x86)\\LyX 2.0\\imagemagick\\convert.exe" -delay 20 -loop 0 files_*.png animation.gif')


I'm a windows 10 user, after defining the working directory I got it working in R using

shell("convert -set delay 80 -loop 0 *.jpg example_shell_test.gif")

within cmd each command means the following

convert = open convert function from ImageMagick

-set delay x = set the delay time between each frame to x (1000 = 1 second)

-loop 0 = loop forever, if set to 1 it will go through the images once

*.[image type]= and file of .[image type]

[name of output gif].gif = save new .gif as

I got it working first within command prompt by navigating to the directory and running the line

convert -set delay 80 -loop 0 *.jpg example_cmd_test.gif

Before this I was using -delay = 80 rather than -set delay 80in cmd and got error:convert: invalid argument for option '-delay': = @ error/convert.c/ConvertImageCommand/1277.

In R using the system() command with the correct "-set delay x" I was getting error:

> system("convert -set delay = 80 -loop 0 *.jpg example_3.gif")Invalid Parameter - delayWarning message:running command 'convert -set delay = 80 -loop 0 *.jpg example_3.gif' had status 4 

other errors in shell()

> shell("convert -set delay = 80 -loop 0 *.jpg example_shell_test11.gif")convert: unable to open image '80': No such file or directory @ error/blob.c/OpenBlob/3094.convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/509.Warning messages:1: running command 'C:\WINDOWS\system32\cmd.exe /c convert -set delay = 80 -loop 0 *.jpg example_shell_test11.gif' had status 1 2: In shell("convert -set delay = 80 -loop 0 *.jpg example_shell_test11.gif") :  'convert -set delay = 80 -loop 0 *.jpg example_shell_test11.gif' execution failed with error code 1

I ran it in R with shell() after and it seems to work fine

shell("convert -set delay = 80 -loop 0 *.jpg example_shell_test.gif")

Do have a look at this thread also

ImageMagick - Issue with Windows and convert function


I know someone else already found the solution to your problem but there is an easier way to solve it without having to include the entire pathway in system(). Simply setani.options(convert = 'pathway/convert.exe')after loading the animation package.