2012-04-09 129 views
2

我剛剛開始探索ImageMagick,我有一個疑問。我一直在尋找,但找不到解決方案。ImageMagick背景圖片?

用下面的代碼:

convert -background lightblue -fill blue -font Candice -pointsize 30 \ 
      -size 220x220 -gravity Center caption:'$txt' \ 
      $name.gif 

如何使用圖片作爲背景,而不是一個靜態的顏色?我試過-background "file.jpg"但它不起作用。

回答

2

使用-texture而不是-background

+2

我試圖用-texture'file.jpg'替換-background'file.jpg',但它帶有白色背景 – user1305628 2012-04-09 21:02:33

0

很依賴你後的效果的幾種方法,但是這是一個簡單的方法:

轉換input.jpg - 填充藍色-font康迪斯-pointsize 30 -gravity中心-annotate + 0 + 0「一些文本「$ name.gif

我不能得到的方式掛這個網站的職位代碼:(

1

我想我missunderstood您最初的問題,這將平鋪圖像投影到一組大小的背景和添加一些文字。

$txt = 'Caption'; 
// Tile the image - no background as it will not be seen behind the tile 
$cmd = " -size 220x220 tile:noise.jpg -font Candice -fill blue -pointsize 30 ". 
"-gravity Center -annotate +0+0 $txt"; 
exec("convert $cmd output.jpg"); 
+0

在OS X上使用ImageMagick時,必須指定字體的完整路徑。convert - size:220x220 tile:/Applications/Chess.app/Contents/Resources/selected_piece_texture.png -fill blue -font/Library/Fonts/Arial \ Narrow.ttf -pointsize 30 -gravity Center -annotate + 0 + 0「some text」output .png'。 – user495470 2012-09-29 05:52:52