2012-07-18 188 views
1

我設法在我的頭像上實現圓角後處理。它在我的Mac上正常工作,但在Windows上沒有骰子。Windows上的回形針/ ImageMagick問題

它看起來像這樣

def self.convert_options(px = 10) 
    trans = "" 
    trans << " \\(+clone -alpha extract " 
    trans << "-draw 'fill black polygon 0,0 0,#{px} #{px},0 fill white circle #{px},#{px} #{px},0' " 
    trans << "\\(+clone -flip \\) -compose Multiply -composite " 
    trans << "\\(+clone -flop \\) -compose Multiply -composite " 
    trans << "\\) -alpha off -compose CopyOpacity -composite " 
end 

基於http://www.imagemagick.org/Usage/thumbnails/#rounded & Rounded corners with Paperclip

錯誤的大名單我踢出了與

convert.exe: unable to open image `\\(': No such file or directory @ error/blob.c/OpenBlob/2638. 

我想,也許是事做Windows轉義字符?所以改變了\ ^到,但得到這個錯誤,而不是

convert.exe: unable to open image `black': No such file or directory @ error/blob.c/OpenBlob/2638. 

ImageMagick的工作,否則。它管理更簡單的處理/調整大小罰款。如果我使用GIT BASH將命令直接輸入到shell中,則該行會生成圓角文件,而不會出現問題。

回答

0

一個良好的夜間睡眠(嘗試成千上萬種組合小時後)使我這個

def self.convert_options_win(px = 10) 
    trans = " " 
    trans << " (+clone -alpha extract -draw \"fill black polygon 0,0 0,#{px} #{px},0 fill white circle #{px},#{px} #{px},0 \" " 
    trans << " (+clone -flip) -compose Multiply -composite " 
    trans << " (+clone -flop) -compose Multiply -composite) " 
    trans << " -alpha off -compose CopyOpacity -composite " 
end 

工作正常。在行首不需要連續字符,因爲它全部被截斷成一行字符串。 Windows shell更喜歡將「雙引號」改爲「單引號」,所以只需要將字符串中的內容轉義即可。我嘗試了這麼多的組合,不敢相信這是這麼簡單。