phpcms紧缩图片的办法:起首找到并关上“extention.func.php”文件;而后正在公共类中写一个主动紧缩的办法;最初经过语句“{compress ($rs[‘thumb’])}”正在html页面中间接挪用便可。
phpcms图片主动紧缩性能
正在公共类中写一个主动紧缩的办法:
phpcms\libs\functions\extention.func.php ** @param $imgName @return mixed|string $imgpath 原图寄存地点 $thumbpath 紧缩后图片寄存门路 */ function compress ($imgName){ imgPath=PHPCMSPATH.trim(imgPath = PHPCMS_PATH . trim(imgPath=PHPCMS P ATH.trim(imgName, ‘/’); $Patharray = explode(’/’, $imgName); fileName=end(fileName = end(fileName=end(Patharray); //创立thumb文件夹,保留紧缩后的图片 header(“Content-type:text/html;charset=utf-8”); $path="/uploadfile/thumb/"; dirPath=PHPCMSPATH.dirPath = PHPCMS_PATH.dirPath=PHPCMS P ATH.path; if(!is_dir(KaTeX parse error: Expected '}', got 'EOF' at end of input: …h)){ mkdir(dirPath,0777,true); } $thumbPath = PHPCMS_PATH . ‘uploadfile/thumb/’ . fileName;if(fileexists(fileName;if (file_exists(fileName;if(file e xists(thumbPath)) { return APP_PATH . ‘uploadfile/thumb/’ . $fileName; }else{ src=imagecreatefromjpeg(src = imagecreatefromjpeg(src=imagecreatefromjpeg(imgPath); srcw=imagesx(src_w = imagesx(src w =imagesx(src); srch=imagesy(src_h = imagesy(src h =imagesy(src); //设置缩略图巨细 $dst_w = $src_w1; $dst_h = $src_h1; dst=imagecreatetruecolor(dst = imagecreatetruecolor(dst=imagecreatetruecolor(dst_w,dsth);//图片采样复制imagecopyresampled(dst_h);//图片采样复制imagecopyresampled(dst h );//图片采样复制imagecopyresampled(dst,src,0,0,0,0,src,0,0,0,0,src,0,0,0,0,dst_w,dsth,dst_h,dst h ,src_w,srch);//保留缩略图imagejpeg(src_h);//保留缩略图imagejpeg(src h );//保留缩略图imagejpeg(dst,thumbPath);//销毁资本imagedestroy(thumbPath);//销毁资本imagedestroy(thumbPath);//销毁资本imagedestroy(src); imagedestroy($dst); thumbPath=strreplace(PHPCMSPATH,"/",thumbPath = str_replace(PHPCMS_PATH,"/",thumbPath=str r eplace(PHPCMS P ATH,"/",thumbPath); return $thumbPath; } }
保举:《phpcms教程》
正在html页面中间接挪用
{compress ($rs[‘thumb’])}
以上就是phpcms怎样紧缩图片的具体内容,更多请存眷资源魔其它相干文章!
标签: phpcms phpcms教程 phpcms技巧 php问题解决
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
抱歉,评论功能暂时关闭!