2017-11-11 121 views
0

如何旋轉文本然後在graphicsmagick中繪製? 這是一個簡單的問題,但我從一個小時以來就無法從API瞭解它。如何旋轉文本然後在graphicsmagick中繪製?

幫助將appriciated,謝謝。 我正在使用gm,但從命令行執行它也足夠了。

此外還有一個關於這個問題的公開問題。 https://github.com/aheckmann/gm/issues/660

如果我們不能用graphicsmagick做到這一點,OpenCV或Imagemagick的替代方案是可能的。

+0

你能更具體嗎?旋轉文本並繪製​​*什麼**? **哪裏**?也許舉個例子吧。 –

回答

1

我同意Mark Setchell。這個問題不明確。在ImageMagick中,您可以通過多種方式繪製旋轉文字。 -annotate函數將通過它的參數來做到這一點。您還可以使用標籤創建一個新的文本圖像:然後旋轉並在背景圖像上進行組合。見http://www.imagemagick.org/Usage/text/http://www.imagemagick.org/script/command-line-options.php#annotate

輸入:

enter image description here

convert logo.jpg -font Arial -pointsize 64 -fill red -gravity center -annotate 20x20+0+0 "TESTING" logo_test.jpg 

或交替使用-draw

convert logo.jpg -font Arial -pointsize 64 -fill red -gravity center -draw "rotate 20 text 0,0 'TESTING'" logo_test2.jpg 

enter image description here

對不起,我不知道GraphicsMagick工具,但它應該有一個類似的操作符來註釋,也許是同一個名字。

+0

在GraphicsMagick的node.js中我找到了這個函數'.draw([「rotate -14 text 0,0」+ yourText])''''''''''''''''''''''''這個答案指出我找到了這個功能,這個功能在之前沒有看到過。謝謝。 –

+0

如果您將使用變量,那麼您的文本當然應該包含轉義或單引號。恩。 'var yourText =「\」示例文本\「」' –