Warning: imagecopyresampled() expects parameter 2 to be resource, null given in E:\demo\test01\image\image.class.php on line 21
<?php
class Image{
private $image;
private $info;
public function _construct($src)
{
$info = getimagesize($src);
$this->info = array(
'width'=>$info[0],
'height'=>$info[1],
'type'=>image_type_to_extension($this->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);
}
}
?>