求大神們解答,小白很無奈
<?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($info['2'],false),
? ? ? ? ? ?"mime"=>$info[mime]
? ? ? ? ? ?);
? ? ? ?$fun="imagecreatefrom{$this->info['type']}";
? ? ? ?$image=$fun($src);
? ?}
? ?//壓縮圖片
? ?public function thumb($width,$height){
? ? ? ?$thumb_img=imagecreatetruecolor($width,$height);
? ? ? ?//參數未定義
? ? ? ?imagecopyresampled($thumb_img,$this->image,0,0,0,0,$width,$height,$this->info['width'],$this->info['height']);
? ? ? ?//出錯
? ? ? ?imagedestroy($this->image);
? ? ? ?$this->image=$thumb_img;
? ?}
? ?//在瀏覽器顯示圖片
? ?public function show(){
? ? ? ?header("Content-type:".$this->info["mime"]);
? ? ? ?$func="image{$this->info['type']}";
? ? ? ?//出錯
? ? ? ?$func($this->image);
? ?}
? ?//保存圖片至硬盤
? ?public function save($newName){
? ? ? ?$funcs="image{$this->info['type']}";
? ? ? ?$funcs($this->image,$newName.'.'.$this->info['type']);
? ?}
? ?//銷毀圖片
? ?public function _destruct(){
? ? ? ?imagedestroy($this->image);
? ?}
}
?>
<?php
require "thumbclass.php";
$src="bg.jpg";
$image=new Image($src);
$image->thumb(300,500);
$image->show();
?>
2017-12-06
你require那里的類名字都不對吧