weiliwei 发表于 2017-4-1 11:52:36

imagick 加水印 php java 乱码

php代码

$draw = new ImagickDraw();            
$draw->setFont('C:\\WINDOWS\\Fonts\\simsun.ttc');   //必须标明字体      
$draw->setFontSize( 12 );   


$file = 'E:\\images\\11.gif';
$animation = new Imagick(); //create animation object   
$animation->setFormat('gif'); // set file type   

$image= new Imagick($file);
$ftype= strtolower($image->getImageFormat());
$num = $image->getNumberImages();
$text = iconv('gb2312', 'utf-8', '*********);//只支持utf-8
//$text = '**********;

//$draw->setTextEncoding("utf-8");

for($i=0;$i<$num;$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 );   
}
$image->destroy();
$image->clear();
header( "Content-Type: image/gif" );   
echo( $animation->getImagesBlob() );

java
只需要指定字体即可。
页: [1]
查看完整版本: imagick 加水印 php java 乱码