Skip to content

Instantly share code, notes, and snippets.

@dervn
Created September 29, 2010 06:36
Show Gist options
  • Save dervn/602370 to your computer and use it in GitHub Desktop.
Save dervn/602370 to your computer and use it in GitHub Desktop.
使用imagick在动态GIF上打文字水印
<?PHP
/*使用imagick在动态GIF上打文字水印*/
$draw = new ImagickDraw();
$draw->setFont('simsun.ttc');
$draw->setFontSize( 12 );
$text = iconv('GB2312', 'UTF-8', '网易');
$image=new Imagick();
$animation = new Imagick();
$animation->setFormat( "gif" );
$image->readImage("52924.gif");
$unitl = $image->getNumberImages();
for ($i=0; $i<$unitl; $i++) {
$image->setImageIndex($i);
$thisimage = new Imagick();
$thisimage->readImageBlob($image);
$delay = $thisimage->getImageDelay();
$thisimage->annotateImage($draw, 0, 12, 0, $text);
$animation->addImage($thisimage);
$animation->setImageDelay( $delay );
}
header( "Content-Type: image/gif" );
echo $animation->getImagesBlob();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment