2017-06-20 22 views
3

從2.5版動畫開始,似乎在Windows 7上調用ImageMagick實用程序convert.exe的路徑仍然存在。這可以通過將轉換選項添加到ani.option來解決。但是,現在新版本7(.0.6.Q16)不包含covert.exe(動態和靜態構建)。在ImageMagick的exe文件的DOS列表給出R:動畫包中的新錯誤:Image.exe中不再存在convert.exe

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 

因此,將R用於創建動畫GIF與法線下面的命令失敗,錯誤

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 

的im.convert幫助沒有提及的可能性缺少convert.exe的。

的R命令我跑的

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")) 

的命令是正確的,並且預期圖像(產生與我的筆記本電腦用的ImageMagick嵌入LyX的-not不確定哪建立的ImageMagick的但CONVERT.EXE是版本6)如圖所示。 enter image description here

我無法安裝Imagemagick版本6,因爲只有版本7的二進制文件出現在website上,change log沒有提到刪除convert.exe實用程序。我不想安裝LyX。

有人可以提出一個解決方案嗎?

更新與解決方案

正如@ fnw42的答覆中提到,在ImageMagick的釋放7

的「magick」命令是殼牌API的新的主命令,取代舊的「轉換「命令。

因此要使用saveGif必須在convert命令選項中反映這種更改。例如,在上面的代碼中一個需要更換convert.exemagick.exe

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

人們也可以調用老轉換實用程序爲「magick轉換」。一些選項現已被棄用,並且已添加了一些新選項。查看porting explanation的詳細信息。

我還發現在sourceforge上有舊的Imagemagick版本。

+0

我們意識到這個問題,並會盡量利用magick'的'在動畫包的下一個版本。謝謝您的耐心等待! –

+0

@Yihui當然,感謝您的辛勤工作!希望這個答案可以幫助您找到最佳的解決方案 –

回答

2

在Imagemagck 7中,您必須用magick(magick.exe)替換convert(convert.exe),除非您從Widows ImageMagick安裝程序安裝舊版組件,然後convert.exe將實際運行IM 6.要運行IM 7,使用magick。見http://imagemagick.org/script/porting.php#cli

對不起,我不知道R.

+0

這就是答案,謝謝。即時通訊網站,但沒有看到這個文件。 –

+0

@ fmw42只是爲了檢查 - 替換你的意思是什麼?重命名magick.exe,或者我在哪裏可以找到安裝文件夾中的convert.exe? – Nick

+0

我不知道Ruby或R,所以我不知道它是如何調用ImageMagick命令的。但是你說你正在使用IM 7並且找不到轉換。在IM 7中,沒有轉換。它更改爲magick,以便命令行ImageMagick 7中的命令從magick開始並不轉換。在Windows中,您可能需要調用magick.exe。 – fmw42