2023-03-17 23:24:11 发布人:hao333 阅读( 3362)
PHP代码<?php ***功能:生成缩略图*作者:phpox*日期:ThuMay1709:57:05CST2007* classCreatMiniature{ 公共变量var$srcFile=""; 原图var$echoType; 输出图片类型,link--不保存为文件;file--保存为文件var$im=""; 临时变
Php代码?Php/***函数:生成缩略图*作者:phpox*日期:thu may 17 09:57:05 CST 2007 */classcreatminiatures {//公共变量var $ srcFile=//原始var $ echoType//输出图片类型,链接-不保存为文件;文件-另存为文件变量$ im=“”;//临时变量var $ srcW=“”;//原始宽度var $ srcH=“”;//原始高度//设置变量并初始化函数setvar ($ srcfile,$ echotype) {if(!File_exists($srcFile)){echo '源图像文件不存在!'exit();} $ this-src file=$ src file;
图像销毁($ cImg);}//生成按比例缩放的缩图函数按比例分配($toFile,$toW,$ toH){ $ toWH=$ toW/$ toH;$ srcWH=$ this-srcW/$ this-srcH;if($ toWH=$ srcWH){ $ ftoW=$ toW;$ ftoH=$ ftoW *($ this-srcH/$ this-srcW);} else { $ ftoH=$ toH $ ftoW=$ ftoH *($ this-srcW/$ this-srcH);} if($this-srcW $ toW | | $ this-srcH $ toH){ $ cImg=$ this-creation image($ this-im,$ftoW,$ftoH,0,0,0,$ this-srcW,$ this-srcH);返回$this-EchoImage($cImg,$ to file);图像销毁($ cImg);}否则{
$ cImg=$ this-creation image($ allImg,$toW,$toH,0,0,($ctoW-$toW)/2,($ctoH-$toH)/2,$toW,$ toH);返回$this-EchoImage($cImg,$ to file);图像销毁($ cImg);图像销毁($ allImg);}//生成背景填充的缩图函数回填($toFile,$toW,$toH,$bk1=255,$bk2=255,$ bk3=255){ $ toWH=$ toW/$ toH;$ srcWH=$ this-srcW/$ this-srcH;if($ toWH=$ srcWH){ $ ftoW=$ toW;$ ftoH=$ ftoW *($ this-srcH/$ this-srcW);}
相关阅读
RelatedReading猜你喜欢
Guessyoulike