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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

瀏覽器無法顯示圖片

瀏覽器無法顯示圖片

PHP
慕粉4279450 2017-05-22 13:43:49
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?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); ???} ???????????? ????} ???? ????<?php? ????require?"image.class.php"; ????$src='timg.jpg'; ????$content="歡迎來到南充農商網"; ????$font_url="simsun.ttc"; ????$size=20; ??????$color=array( ?????????0?=>?255, ?????????1?=>?255, ?????????2?=>?255, ?????????3?=>?20 ?????); ?????$local=array( ????????'x'=>20, ????????'y'=>30 ??????); ????$angle=10; ????$image=new?Image($src); ????$image->fontMark($content,$font_url,$size,$color,$local,$angle); ????$image->show(); ?>
查看完整描述

1 回答

?
orangewangjie3473319

TA貢獻5條經驗 獲得超2個贊

數組引用加引號,我測試過的
imagettftext($this->image,$size,$angle,$local['x'],$local['y'],$col,$font_url,$content);

查看完整回答
2 反對 回復 2017-05-27
  • 1 回答
  • 0 關注
  • 1261 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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