国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

圖片添加文字水印 和圖片水印

2019-11-15 02:05:39
字體:
來源:轉載
供稿:網友
圖片添加文字水印 和圖片水印
<?php    /**     * @desc 圖片處理類     */     class Pic{        PRivate $info;        private $res;        public $thumb_pic;        public function __construct($picPath){            //獲取圖片信息            $this->info = getimagesize($picPath);            //獲取圖片名            $this->info['type'] = image_type_to_extension($this->info[2],false);            $funs = 'imagecreatefrom'.$this->info['type'];            $this->res = $funs($picPath);        }        //縮略圖        public function thumb($w=100,$h=100){            //創建圖片資源            $image_thumb = imagecreatetruecolor($w,$h);            imagecopyresampled($image_thumb,$this->res,0,0,0,0,$w,$h,$this->info[0],$this->info[1]);            imagedestroy($this->res);            $this->res = $image_thumb;        }        //展示        public function showPic(){            header('Content-type:'.$this->info['type']);            $funs = 'image'.$this->info['type'];            $funs($this->res);                }                //保存        public function savePic($newname){            $funs = 'image'.$this->info['type'];            $funs($this->res,$newname.".".$this->info['type']);                        }                //銷毀圖片        public function __destruct(){            imagedestroy($this->res);                }        /**         * @desc  添加文字水印         * @param $content string    文字         * @param $fonturl string     字體路徑         * @param $fontsize int       字體大小         * @param $fontcolor array     設置顏色和透明度         * @param $local array      水印坐標         * @param $fontangle int    字體旋轉角度         */        public function fontMark($content,$fonturl,$fontsize,$fontcolor,$local,$fontangle){            $color = imagecolorallocatealpha($this->res,$fontcolor[0],$fontcolor[1],$fontcolor[2],$fontcolor[3]);            imagettftext($this->res,$fontsize,$fontangel,$local['x'],$local['y'],$color,$fonturl,$content);                }        /**         * @desc  添加圖片水印         * @param $markPic string 水印圖片         * @param $local array     圖片坐標         * @param $alpha array     設置顏色和透明度         */        public function picMark($markPic,$local,$alpha){            $markInfo = getimagesize($markPic);            $markType = image_type_to_extension($markInfo[2],false);            $markFun = 'imagecreatefrom'.$markType;            $markWater = $markFun($markPic);            imagecopymerge($this->res,$markWater,$local['x'],$local['y'],0,0,$markInfo[0],$markInfo[1],$alpha);            imagedestroy($markWater);                }     }     $pic = new Pic('yibo_pic28.jpg');     $pic->picMark('logo3.png',array('x'=>50,'y'=>50),30);     $pic->showPic();


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永吉县| 北辰区| 金湖县| 阿拉善左旗| 建阳市| 惠东县| 偃师市| 利辛县| 太康县| 河源市| 日喀则市| 周口市| 浦北县| 桦川县| 镇平县| 伊宁市| 虹口区| 厦门市| 拜泉县| 铁岭县| 乌兰察布市| 新蔡县| 哈巴河县| 中宁县| 鄱阳县| 游戏| 沙雅县| 平舆县| 将乐县| 蒙阴县| 江阴市| 独山县| 蒙山县| 丰原市| 石嘴山市| 芦溪县| 玛多县| 汉寿县| 泽普县| 扬州市| 章丘市|