亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

求正確代碼?我這個不對啊

?<?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($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']);
			$funs?=?"image{$this->info['type']}";
			$funs($this->image);
		}

		/**
		*	把圖片保存在硬盤里
		*/
		public?function?save($newname){
			$funs?=?"image{$this->info['type']}";
			$funs($this->image,$newname.'.'.$this->info['type']);
		}

		/**
		*?銷毀圖片
		*/
		public?function?__destruct(){
			imagedestroy($this->image);
		}

	}
?>


正在回答

1 回答

40行代碼有問題???header('Content-type:',$this->info['mime']);

應該是?header('Content-type:'.$this->info['mime']);

如何還是不行就試試這個

<?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($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?fontMark($content,$font_url,$size,$color,$local,$angle){
			$col?=?imagecolorallocatealpha($this->image,$color[0],$color[1],$color[2],$color[3]);
			imagettftext($this->image,$size,$angle,$local['x'],$local['y'],$col,$font_url,$content);
		}
		
		/*添加圖片水印*/
		public?function?imageMark($source,$local,$alpha){
			$info2?=?getimagesize($source);
			$type2?=?image_type_to_extension($info2[2],false);
			$fun2?=?"imagecreatefrom{$type2}";
			$water?=?$fun2($source);
			imagecopymerge($this->image,$water,$local['x'],$local['y'],0,0,$info2[0],$info2[1],$alpha);
			imagedestroy($water);
		}

		/*輸出圖片*/
		public?function?show(){
			header("content-type:".$this->info['mime']);
			$funs?=?"image{$this->info['type']}";
			$funs($this->image);
		}
		/*保存圖片*/
		public?function?save($newname){
			$funs?=?"image{$this->info['type']}";
			$funs($this->image,$newname.'.'.$this->info['type']);	
		}
		/*銷毀圖片*/
		public?function?__destruct(){
			imagedestroy($this->image);
		}
	}
?>


0 回復 有任何疑惑可以回復我~
#1

俠客島的含笑 提問者

非常感謝!
2017-03-24 回復 有任何疑惑可以回復我~
#2

語沫流逝 回復 俠客島的含笑 提問者

不用謝?。。。。?/div>
2017-03-24 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

求正確代碼?我這個不對啊

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號