R: new animation package bug: convert.exe is no longer in Imagemagick

Starting with version 2.5 of the animation, it seems that the error with the path to invoke the ImageMagick convert.exe utility in Windows 7 is still present. This can be fixed by adding the convert option to ani.option. However, now new version 7 (.0.6.Q16) does not contain covert.exe (both dynamic and static assemblies). The list of EXE files in ImageMagick gives

Directory of C:\Program Files\ImageMagick-7.0.6-Q16

11/Jun/17  12:10 PM           828,416 dcraw.exe
11/Jun/17  12:08 PM        33,351,680 ffmpeg.exe
11/Jun/17  12:08 PM           113,664 hp2xx.exe
11/Jun/17  12:14 PM        16,340,480 imdisplay.exe
11/Jun/17  12:14 PM        16,471,552 magick.exe
20/Jun/17  11:22 AM         1,202,385 unins000.exe
6 File(s)     68,308,177 bytes

Directory of C:\Program Files\ImageMagick-7.0.6-Q16\uninstall

11/Jun/17  12:07 PM           122,279 PathTool.exe
1 File(s)        122,279 bytes

Total Files Listed:
7 File(s)     68,430,456 bytes

      

Hence the R commands to create an animated GIF with the normals below fail with an error

Executing: 
""C:\Program Files\ImageMagick-7.0.6-Q16\convert.exe" -loop 0 -delay 12 Rplot1.png Rplot2.png Rplot3.png
    Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png Rplot11.png Rplot12.png
    Rplot13.png Rplot14.png Rplot15.png Rplot16.png Rplot17.png Rplot18.png Rplot19.png Rplot20.png
    "Normals1_Ani.gif""
'"C:\Program Files\ImageMagick-7.0.6-Q16\convert.exe"' is not recognized as an internal or external command,
operable program or batch file.
an error occurred in the conversion... see Notes in ?im.convert
[1] FALSE

      

The im.convert help does not mention the possibility of losing the convert.exe file.

The R commands that I ran are

 library(animation)
 donorm = function(k){
   require(ggplot2)
   Ns = matrix(0, 1000, k)
   X = matrix(0, 1000, k)
   for (i in 1:k){
     X[, i] = sort(rnorm(1000, mean = ifelse(i<11,0,2), sd = 0.5*ifelse(i<11,sqrt(i), sqrt(i -10))))
     Ns[, i] = dnorm(X[,i], mean = ifelse(i<11,0, 2), sd = 0.5*ifelse(i<11,sqrt(i), sqrt(i -10)))
   }
   mx = c(min(X), max(X))
   my = max(Ns)
   dat = data.frame(x = rep(0, 1000), y = rep(0, 1000))
   for (i in 1:k){
     dat$x = X[,i]; dat$y = Ns[,i]
     pl = ggplot2::ggplot(dat, aes(x = x, y= y)) + geom_line(color = i%%5 + 1, size = 1.5) + 
     coord_cartesian(xlim = mx, ylim = c(0, my)) +
     annotate("text", x = mx[1]+0.25, y = my[2]-0.25, label = 
                paste("mean = ", round(ifelse(i<11,0,2),1),"//st.dev = ", round(0.5*ifelse(i<11,sqrt(i), sqrt(i -10)), 1))) +
       theme_bw()
     print(pl)
   }
 }

## this is suggested solution for calling convert.exe but it fails on my system
# path_to_convert <- paste0(shortPathName("C:\\Program Files\\ImageMagick-7.0.6-Q16\\"), "convert.exe")

## this would work were the exe there
path_to_convert = "\"C:\\Program Files\\ImageMagick-7.0.6-Q16\\convert.exe\""

animation::ani.options(interval = 0.12, ani.width = 480, ani.height = 320, convert=path_to_convert)
animation::saveGIF(donorm(20), movie.name = paste0("Normals",1,"_Ani.gif"))

      

The commands are correct and the expected image (generated with my laptop with ImageMagick embedded in LyX - not sure which build of ImageMagick, but convert.exe is version 6) as shown. enter image description here

I cannot install Imagemagick version 6 because the website only has binaries for version 7, the changelog does not mention uninstalling the convert.exe utility. I would rather not have LyX installed.

Can anyone suggest a solution?

UPDATE with solution

As mentioned in @ fnw42's answer, in ImageMagick release 7

The "magick" command is the new primary Shell API command, replacing the old "convert" command.

So, to use it saveGif

, you need to reflect this change in the conversion command option. For example, in the above code, you need to replace convert.exe

with magick.exe

, as in

path_to_convert = "\"C:\\Program Files\\ImageMagick-7.0.6-Q16\\magick.exe\""

      

You can also use an old conversion utility like "magick convert". Some parameters are now deprecated and some are new. Learn more about the porting explanation .

I also found that older versions of Imagemagick are available at sourceforge .

+3


source to share


1 answer


In Imagemagck 7, you have to replace convert (convert.exe) with magick (magick.exe, unless you installed legacy components from the Widows ImageMagick installer. Then convert.exe will actually launch IM 6. To launch IM 7, use magic. See http://imagemagick.org/script/porting.php#cli



Sorry, I don't know R.

+2


source







All Articles