*@param string $filename 要转存的文件路径
*@param int $zhiliang jpeg图片特有的,图像清晰度
*/
function display($type = null,$filename = null,$zhiliang = null) {
if($type == null) {
$type = $this->type ? $this->type : 'jpg';
}
if(($type == 'jpeg' or $type == 'jpg') and $zhiliang == null) {
$type = 'jpeg';
$zhiliang = 100;
}
if($filename == null) {
header('Content-type: image/'.$type);
}
$displayfunc = 'image'.$type;
$displayfunc($this->im,$filename,$zhiliang);
imagedestroy($this->im);
}
function randcolor($a,$b) {
$a = $a>255 ? 255 : (int)$a;
$a = $a<0 ? 0 : (int)$a;
$b = $b>255 ? 255 : (int)$b;
$b = $b<0 ? 0 : (int)$b;
for($i=0;$i<3;$i++) {
$color .= str_pad(dechex(mt_rand($a,$b)), 2, "0", STR_PAD_LEFT);
}
return $color;
}
}
/*
function error($msg,$debug = false) {
$err = new Exception($msg);
$str = "<pre>n<span style="color:red" style="color:red">错误:</span>n".print_r($err->getTrace(),1)."n</pre>";
if($debug == true) {
file_put_contents(date('Y-m-d').".log",$str);
return $str;
}else{
die($str);
}
}
*/
?>
这是简单的用法实例
$img = new img('a.png');
$m = $img->im;
$im = $img->suolue(100);
$img->im = $m;
$img->suolue(300);
$img->merge($m,array('left'=>0,'top'=>0,'touming'=>60));







