Reputation: 63
I am using Windows 7 on a 32 bit computer. I have installed ImageMagick-7.0.4-4-Q16-x86-dll.exe. I have added path to ImageMagick in Path of Environmetal Variables. Using convert --version in command prompt shows ImageMagick correctly (but not when I run it in R using system()). Now, I try to make an animated gif file using the following R code (taken from another stackoverflow post):
library(animation)
ani.options('C:/Program Files/ImageMagick-7.0.4-Q16/convert.exe')
dir.create("examples")
setwd("examples")
png(file="example%02d.png",width=200, height=200)
for(i in c(10:1,"GO!")){
plot.new()
text(.5,.5,i,cex=6)
}
dev.off()
No error message shows as of yet. But when I write the following line:
system("convert -delay 80 *.png example_1.gif")
it throws the following error:
Invalid parameter - 80 Warning message: running command 'convert -delay 80 *.png example_1.gif' had status 4
After this, I ran the following command
system("convert --version")
and it throws the following error:
Invalid drive specification Warning message: running command 'convert --version' had status 4
I tried to solve this by running RStudio in administrator mode but in vain.
Upvotes: 0
Views: 1924
Reputation: 207465
There is a Microsoft tool called CONVERT.EXE
that has clashed with the ImageMagick tool of the same name for years.
Version 7 of ImageMagick has a new command-name, namely magick
, which you can use in place of convert
, identify
mogrify
and the other commands in the ImageMagick suite.
So,
identify image.png
becomes
magick identify image.png
And
convert image.png -resize 10x10 result.png
becomes
magick image.png -resize 10x10 result.png
Apart from that, you need to ensure that the PATH that R is using includes the directory that contains magick.exe
.
You also need to ensure that the system()
shell is running in the directory where your images are, so you can check where it is running like this:
system("pwd")
If it is not running in the directory where your images are, you can either use an absolute path to your images (i.e. one that begins from the top of the drive, like "C:\User\Fred\FunkyImages\Image1.jpg") or you can change directory inside the system()
command before you do your processing:
system("cd somewhere && do something")
Upvotes: 3