2017-04-23 72 views
1

我想從一系列R圖中製作一個GIF動畫文件。我安裝了ImageMagick和「動畫」包來做到這一點。R {animation} package [saveGIF] - 想用magick代替convert

我想使用saveGIF函數,但是當我使用該函數時,它會嘗試在ImageMagick中使用convert.exe並給出錯誤。它看起來像當前版本的ImageMagick使用magick.exe而不是convert.execonvert.exe不存在)。

我能夠使用magick.exe直接從ImageMagick製作GIF動畫,而不使用動畫包。但如果我可以使saveGIF使用magick.exe而不是convert.exe,那對我來說更方便。我想知道如何去做。

安裝舊版ImageMagick仍然使用convert.exe將解決問題,但這不是我正在尋找的答案。

UPDATE

我試圖ani.options由Josh奧布萊恩建議。以下是我得到的。不知道什麼問題...

> ani.options(convert = 'C:/Program Files/ImageMagick-7.0.5-Q16/magick.exe') 
> 
> saveGIF(
+ for(i in 1:10){ 
+ plot(i,1,xlim=c(0,11)) 
+ } 
+) 
Executing: 
"C:/Program Files/ImageMagick-7.0.5-Q16/magick.exe -loop 0 -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png 
    Rplot8.png Rplot9.png Rplot10.png "animation.gif"" 
'C:/Program' 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 
Warning messages: 
1: running command 'C:\WINDOWS\system32\cmd.exe /c "C:/Program Files/ImageMagick-7.0.5-Q16/magick.exe -loop 0 -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "animation.gif""' had status 1 
2: In cmd.fun(convert) : 
    '"C:/Program Files/ImageMagick-7.0.5-Q16/magick.exe -loop 0 -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "animation.gif""' execution failed with error code 1 
3: running command '"C:/Program Files/ImageMagick-7.0.5-Q16/magick.exe -loop 0 -delay 100 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png Rplot9.png Rplot10.png "animation.gif""' had status 127 
+1

您是否嘗試過使用'ani.options(convert ='/path/to/magick.exe')'來修復可執行文件的路徑? –

+0

@Josh O'Brien謝謝。有效。 – quibble

回答

4

喬希奧布賴恩的答案工作。 「程序文件」必須更改爲「PROGRA_1」。

ani.options(convert = 'C:/PROGRA~1/ImageMagick-7.0.5-Q16/magick.exe') 

saveGIF(
for(i in 1:10){ 
plot(i,1,xlim=c(0,11)) 
} 
) 
+0

它爲我工作。關鍵是改爲「PROGRA〜1」而不是「Program Files」 –