【www.gdgbn.com--php常用代码】

 代码如下 $imagedraw = new imagick();
$pixel = new imagickpixel("gray");
$pixel->setcolor("black");
$imagedraw->newimage(100, 75, $pixel);
$draw = new imagickdraw();
$draw->setfont("bookman-demiitalic");
$draw->setfontsize(12);
$image=new imagick();
$animation = new imagick();
$animation->setformat( "gif" );
$image->readimage("old.gif");
$unitl = $image->getimageindex();
$image->writeimages("animation.gif",false);
$delay = $image->getimagedelay();
$filename = "animation-";
for ($i=0; $i<$unitl; $i++) {
    $thisimage = new imagick();
    $thisimage->readimage($filename.$i.".gif");
    $thisimage->annotateimage($draw, 0, 12, 0, "copyright by mpeg");
    $animation->addimage($thisimage);
    $animation->setimagedelay($delay);
}       
header("content-type: image/gif");
echo $animation->getimagesblob();
?>

imagemagick功能的php扩展。使用这个扩展可以使php具备和imagemagick相同的功能。   imagemagick是一套功能强大、稳定而且免费的工具集和开发包,可以用来读、写和处理超过185种基本格式的图片文件,包括流行的tiff, jpeg, gif, png, pdf以及photocd等格式。利用imagemagick,你可以根据web应用程序的需要动态生成图片, 还可以对一个(或一组)图片进行改变大小、旋转、锐化、减色或增加特效等操作,并将操作的结果以相同格式或其它格式保存。

组件下载地址

http://pecl.php.net/package/imagick
http://www.imagemagick.org

本文来源:http://www.gdgbn.com/jiaocheng/27651/