117384790 發表於 2019-8-20 19:20:32

图片处理类 class_image.php 使用说明

<ol><li>/**<br /><li>* 图片处理类<br /><li>*<br /><li>* @example<br /><li>*<br /><li>* require_once libfile('class/image');<br /><li>* $img = new image;<br /><li>* $r = $img-&gt;Thumb($attachfile, '', $w, $h, 'fixwr');&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;//生成 $attachfile.'thumb.jpg' 为文件名的缩略图<br /><li>* $r = $img-&gt;Thumb($attachfile, 'temp/test.jpg', $w, $h, 'fixwr');&nbsp; &nbsp; //生成 /data/attachment/test/test.jpg' 为文件名的缩略图<br /><li>* if($r) {<br /><li>*&nbsp; &nbsp; $isthumb = $r;<br /><li>* } else {<br /><li>*&nbsp; &nbsp; $error = $img-&gt;error();<br /><li>*&nbsp; &nbsp; showmessage('Thumb Error');<br /><li>* }<br /><li>*<br /><li>* $r = $img-&gt;Watermark($attachfile);&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;//为 $attachfile 加水印<br /><li>* if(!$r) {<br /><li>*&nbsp; &nbsp; $error = $img-&gt;error();<br /><li>*&nbsp; &nbsp; showmessage('Watermark Error');<br /><li>* }<br /><li>*<br /><li>*/</ol><ol><li>/*<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* $this-&gt;error() 返回值(用于处理失败时)<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*&nbsp; &nbsp;&nbsp;&nbsp;0: 图片不符合处理条件,无需处理正常退出<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*&nbsp; &nbsp; -1: $source 为无效的图片文件<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*&nbsp; &nbsp; -2: 文件权限不足无法处理图片($source 图片无法读取、$target 路径不可写)<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*&nbsp; &nbsp; -3: 系统设置错误无法处理图片<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*&nbsp; &nbsp; -4: 服务器缺少处理图片所需的功能<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*/</ol><ol><li>/**<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* 生成图片的缩略图<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @param $source 图片源路径<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @param $target 生成的缩略图路径,路径为相对 data/attachment/ 的文件名<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*&nbsp; &nbsp; 本地图片省略时自动加后缀 .thumb.jpg,远程图片无法省略<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @param $thumbwidth 缩略宽度<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @param $thumbheight 缩略高度<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @param $thumbtype 缩略方法<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*&nbsp; &nbsp; fixnone / 1 : 小于指定大小、保持比率(默认)<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*&nbsp; &nbsp;&nbsp; &nbsp;fixwr / 2 : 与指定大小相同、保持比率,超出部分剪切<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @param $nosuffix 缩略图路径不加 .thumb.jpg 后缀<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @return 是否处理完毕<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*/<br /><li>&nbsp; &nbsp; function Thumb($source, $target, $thumbwidth, $thumbheight, $thumbtype = 1, $nosuffix = 0)</ol><ol><li>/**<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* 生成图片的水印<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @param $source 图片源路径<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @param $target 生成的图片路径,省略表示同 $source<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @param $type forum - 论坛; portal - 门户; album - 空间相册<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;* @return 是否处理完毕<br /><li>&nbsp; &nbsp;&nbsp;&nbsp;*/<br /><li>&nbsp; &nbsp; function Watermark($source, $target = '', $type = 'forum')</ol><br /><br />图片<em>, </em>处理<em>, </em>class<em>, </em>image<em>, </em>php
頁: [1]
查看完整版本: 图片处理类 class_image.php 使用说明