我嘗試在gif動畫添加文字與ImageMagick的:添加對gif動畫文字與ImageMagick的和PHP
$source = public_path().'/test.gif';
$output = public_path().'/test2.gif';
$text = 'the cake is a lie';
// Create objects
$image = new Imagick($source);
// Create a new drawing palette
$draw = new ImagickDraw();
// Set font properties
$draw->setFont(public_path().'/fonts/Impact.ttf');
$draw->setFontSize(20);
$draw->setFillColor('black');
// Position text at the bottom-right of the image
$draw->setGravity(Imagick::GRAVITY_SOUTHEAST);
// Draw text on the image
$image->annotateImage($draw, 10, 12, 0, $text);
// Draw text again slightly offset with a different color
$draw->setFillColor('white');
$image->annotateImage($draw, 11, 11, 0, $text);
// Set output image format
$image->setImageFormat('gif');
$image->writeImage($output);
但有了這個代碼的圖像不再動畫和質量是非常糟糕的,任何想法?
謝謝,但我怎麼能這樣執行命令?只有exec()?這個命令中的文本部分在哪裏?再次感謝 – Tahola 2014-11-23 14:33:20
的文字註釋會做,我把'<做標記的位置>'。您可以使用自己的代碼進行標記,也可以使用我添加到我的答案中的兩個PHP函數。 – 2014-11-23 15:00:08