出错:imagecopyresampled() expects parameter 2 to be resource, null given in F:\PHP\muke\syin\images\image.class.php on line 27
<?php
class Image{
private $image;
private $info;
//打开图片
public function ww($src){
//图片信息
$info=getimagesize($src);
$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($src);
}
//压缩操作
public function thumb($width,$height)
{
$image_thumb=imagecreatetruecolor($width,$height);
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 show(){
header("Content-type".$this->info['mime']);
$func="image{$this->info['type']}";
$func($this->image);
}
//保存到硬盘中
public function save($newname){
$func="image{$this->info['type']}";
$func($this->image,$newname.'.'.$this->info['type']);
}
//销毁图片
public function __destruct(){
imagedestroy($this->image);
}
}
?>