2016-08-08 5 views
1

imageMagickでアニメーションGIFにウォーターマークを追加する必要があります。
しかし、私は問題があります!

マイコード:
imageMagick(PHP)でアニメーションGIFにウォーターマークを追加

<?php 
$image = new Imagick(); 
$image->readImage("orginal.gif"); 

$watermark = new Imagick(); 
$watermark->readImage("watermark.png"); 

// how big are the images? 
$iWidth = $image->getImageWidth(); 
$iHeight = $image->getImageHeight(); 
$wWidth = $watermark->getImageWidth(); 
$wHeight = $watermark->getImageHeight(); 

if ($iHeight < $wHeight || $iWidth < $wWidth) { 
// resize the watermark 
$watermark->scaleImage($iWidth, $iHeight); 

// get new size 
$wWidth = $watermark->getImageWidth(); 
$wHeight = $watermark->getImageHeight(); 
} 

// calculate the position 
$x = ($iWidth - $wWidth)/2; 
$y = ($iHeight - $wHeight)/2; 

$image->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y); 

header("Content-Type: image/" . $image->getImageFormat()); 
echo $image; 
?> 

オリジナルGIF:
See Original GIF

出力GIF:
See Output GIF

ウォーターマークを作成した後、私のGIFはアニメーション化されません!
どうすれば修正できますか?

+1

イメージを結合して各フレームにウォーターマークを適用し、http://php.net/manual/en/imagick.coalesceimages.phpを再アセンブルする必要があります –

答えて

1

ウォーターマークを付けるコードが見つかりました。アニメーションでは、各フレームを区切り、透かしを入れて戻す必要があります。チェックアウト:coalesce

+0

Snap !!!!!!! !!!! –

+1

偉大な心は似ていると思います – Bonzo

関連する問題