`
wxw850227
  • 浏览: 68998 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

imagick 加水印 php java 乱码

    博客分类:
  • php
阅读更多
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
只需要指定字体即可。 
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics