这篇文章主要为大家展示了“TP框架下GD图片处理类的实现思路”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“TP框架下GD图片处理类的实现思路”这篇文章吧。
<?php
class ImageTool{
private $info;
private $p_w_picpath;
public function __construct($src){
$info=getp_w_picpathsize($src);
$this->info=array(
'width'=>$info[0],
'height'=>$info[1],
'type'=>p_w_picpath_type_to_extension($info[2],false),
'mime'=>$info['mime']
);
$fun="p_w_picpathcreatefrom{$this->info['type']}";
$this->p_w_picpath=$fun($src);
}
public function getImage(){
return $this->p_w_picpath;
}
public function getInfo(){
return $this->info;
}
public function thumb($width,$height){
$p_w_picpath_thumb=p_w_picpathcreatetruecolor($width,$height);
p_w_picpathcopyresampled($p_w_picpath_thumb,$this->p_w_picpath,0,0,0,0,$width,$height,$this->info['width'],$this->info['height']);
p_w_picpathdestroy($this->p_w_picpath);
$this->p_w_picpath=$p_w_picpath_thumb;
}
public function fontMark($fontfile,$text){
//红绿蓝=白+50透明度字体
$col=p_w_picpathcolorallocatealpha($this->p_w_picpath, 255, 255, 255, 50);
//图片字体合成-参数:图像,字体大小,偏转角度,横向偏移,纵向偏移,颜色,字体文件,内容
p_w_picpathttftext($this->p_w_picpath, 50, 0, 40, $this->info['height']-50, $col, $fontfile, $text);
}
public function p_w_picpathMark($water,$waterInfo){
p_w_picpathcopymerge($this->p_w_picpath,$water,20,30,0,0,$waterInfo['width'],$waterInfo['height'],20);
p_w_picpathdestroy($water);
}
public function showInHtml(){
header("content-type:".$this->info['mime']);
$funs="p_w_picpath{$this->info['type']}";
$funs($this->p_w_picpath);
}
public function saveImage($newName){
$funs="p_w_picpath{$this->info['type']}";
$funs($this->p_w_picpath,"$newName.".$this->info['type']);//保存图片
}
public function __destruct(){
p_w_picpathdestroy($this->p_w_picpath);
}
}
以上是“TP框架下GD图片处理类的实现思路”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程网行业资讯频道!