php 图片水印字体不显示,图片可以显示但是不显示水印文字,封装好的压缩图片和没有封装的文字水印都能运行...

require "imageClass.php";

$src = '250px-Wtybill.jpeg';

$image = new Image($src);

$font_url = "msyh.ttc";

$content = "wtybill";

$color = array(

0=>255,

1=>225,

2=>225,

);

$transparency = 30;

$size = 20;

$rotate = 10;

$move = array(

'x'=>20,

'y'=>30

);

$image->fontMark($font_url,$content,$color,$transparency,$Size,$rotate,$move);

$image->show();

$image->save(success);

?>

封装-压缩图片

class Image{

private $info;

public $image;

public function __construct($str){

$info = getimagesize($str);

$this->info = array(

'width'=>$info[0],

'height'=>$info[1],

'type'=>image_type_to_extension($info[2],false),

'mime'=>$info['mime'],

);

$fun = "imagecreatefrom{$this->info['type']}";

$this->image = $fun($str);

}

public function thumb($width,$height){

$image_thumb = imagecreatetruecolor(300,200);

imagecopyresampled($image_thumb,$this->image,0,0,0,0,$width,$height,$this->info['width'],$this->info['height']);

imagedestroy($this->image);

$this->image =$image_thumb;

}

public function fontMark($font_url,$content,$color,$transparency,$Size,$rotate,$move){

$col = imagecolorallocatealpha($this->image,$color[0],$color[1],$color[2],$transparency);

imagettftext($this->image,$size,$rotate,$move['x'],$move['y'],$col,$font_url,$content);

}

public function show(){

ob_clean();

header("content-type:".$this->info['mime']);

$funs = "image{$this->info['type']}";

$funs($this->image);

}

public function save($newname){

$funs = "image{$this->info['type']}";

$funs($this->image,$newname.".".$this->info['type']);

}

public function __destruct(){

imagedestroy($this->image);

}

}

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值