-----------
*/
static function thumb($image,$type='',$filename='',$maxWidth=200,$maxHeight=50,$interlace=true,$suffix='_thumb')
{
// 鑾峰彇鍘熷浘淇℃伅
$info = Image::getImageInfo($image);
if($info !== false) {
$srcWidth = $info['width'];
$srcHeight = $info['height'];
$pathinfo = pathinfo($image);
$type = $pathinfo['extension'];
$type = empty($type)?$info['type']:$type;
$type = strtolower($type);
$interlace = $interlace? 1:0;
unset($info);
$scale = min($maxWidth/$srcWidth, $maxHeight/$srcHeight); // 璁$畻缂╂斁姣斾緥
// 缂╃暐鍥惧昂瀵?
$width = (int)($srcWidth*$scale);
$height = (int)($srcHeight*$scale);
// 杞藉叆鍘熷浘
$createFun = 'ImageCreateFrom'.($type=='jpg'?'jpeg':$type);
$srcImg = $createFun($image);
//鍒涘缓缂╃暐鍥?
if($type!='gif' && function_exists('imagecreatetruecolor'))
$thumbImg = imagecreatetruecolor($width, $height);
else
$thumbImg = imagecreate($width, $height);
// 澶嶅埗鍥剧墖
if(function_exists("ImageCopyResampled"))
ImageCopyResampled($thumbImg, $srcImg, 0, 0, 0, 0, $width, $height, $srcWidth,$srcHeight);
else
ImageCopyResized($thumbImg, $srcImg, 0, 0, 0, 0, $width, $height, $srcWidth,$srcHeight);
if('gif'==$type || 'png'==$type) {
//imagealphablending($thumbImg, false);//鍙栨秷榛樿鐨勬贩鑹叉ā寮?
//imagesavealpha($thumbImg,true);//璁惧畾淇濆瓨瀹屾暣鐨?alpha 閫氶亾淇℃伅
$background_color = imagecolorallocate($thumbImg, 0,255,0); // 鎸囨淳涓涓豢鑹?
imagecolortransparent($thumbImg,$background_color); // 璁剧疆涓洪忔槑鑹诧紝鑻ユ敞閲婃帀璇ヨ鍒欒緭鍑虹豢鑹茬殑鍥?
}
// 瀵筳peg鍥惧舰璁剧疆闅旇鎵弿
if('jpg'==$type || 'jpeg'==$type) imageinterlace($thumbImg,$interlace);
//$gray=ImageColorAllocate($thumbImg,255,0,0);
//ImageString($thumbImg,2,5,5,"Think
PHP",$gray);
// 鐢熸垚鍥剧墖
$imageFun = 'image'.($type=='jpg'?'jpeg':$type);
$filename = empty($filename)? substr($image,0,strrpos($image, '.')).$suffix.'.'.$type : $filename;
$imageFun($thumbImg,$filename);
ImageDestroy($thumbImg);
ImageDestroy($srcImg);
return $filename;
}
return false;
}
/**
+----------------------------------------------------------
* 鐢熸垚鍥惧儚楠岃瘉鐮?
+----------------------------------------------------------
* @static
* @access public
+----------------------------------------------------------
* @param string $length 浣嶆暟
* @param string $mode 绫诲瀷
* @param string $type 鍥惧儚鏍煎紡
* @param string $width 瀹藉害
* @param string $height 楂樺害
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
static function buildImageVerify($length=4,$mode=1,$type='png',$width=48,$height=22,$verifyName='verify')
{
$randval = build_verify($length,$mode);
$_SESSION[$verifyName]= md5($randval);
$width = ($length*9+10)>$width?$length*9+10:$width;
if ( $type!='gif' && function_exi