Call to undefined function imagecreatefrom() 出现这样的报错
<?php class image{ private $info; private $image; //打开图片 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); } } ?>
Fatal error: Call to undefined function imagecreatefrom() in D:\phpStudy\WWW\web\image.class.php on line 17