{"id":94,"title":"php\u56fe\u50cf\u88c1\u5207\u539f\u7406","good":0,"bad":0,"hit":2064,"created_at":"2014-08-16 18:51:15","content":"

<\/p>

\/** * \u751f\u6210\u7279\u5b9a\u5c3a\u5bf8\u7f29\u7565\u56fe \u89e3\u51b3\u539f\u7248\u7f29\u7565\u56fe\u4e0d\u80fd\u6ee1\u8db3\u7279\u5b9a\u5c3a\u5bf8\u7684\u95ee\u9898 PS\uff1a\u4f1a\u88c1\u6389\u56fe\u7247\u4e0d\u7b26\u5408\u7f29\u7565\u56fe\u6bd4\u4f8b\u7684\u90e8\u5206 * @param string $image  \u539f\u56fe\u8def\u5f84 * @param string $thumbname \u7f29\u7565\u56fe\u6587\u4ef6\u540d\uff08\u5e26\u8def\u5f84\u5219\u751f\u6210\u5728\u6307\u5b9a\u8def\u5f84\u4e0b\uff09 * @param string $type \u56fe\u50cf\u683c\u5f0f * @param int $x,$y\u5728\u56fe\u50cf\u4e0a\u9009\u533a\u7684\u5de6\u4e0a\u89d2\u5750\u6807 * @param string $maxWidth  \u751f\u6210\u7f29\u7565\u56fe\u5bbd\u5ea6 * @param string $maxHeight  \u751f\u6210\u7f29\u7565\u56fe\u9ad8\u5ea6 * @param int $selectWidth $selectHeight \u6240\u9009\u533a\u57df\u56fe\u50cf\u7684\u5c3a\u5bf8 * @param boolean $interlace \u542f\u7528\u9694\u884c\u626b\u63cf * @return void *\/function thumb($image, $thumbname, $type='',$x,$y, $maxWidth=100, $maxHeight=100,$selectWidth,$selectHeight, $interlace=true){        \/\/ \u83b7\u53d6\u539f\u56fe\u4fe1\u606f        $info =getImageInfo($image);        if ($info !== false) {            $type = empty($type) ? $info['type'] : $type;            $type = strtolower($type);            $interlace = $interlace ? 1 : 0;            unset($info);            \/\/ \u8f7d\u5165\u539f\u56fe            $createFun = 'ImageCreateFrom' . ($type == 'jpg' ? 'jpeg' : $type);            $srcImg = $createFun($image);\/\/\u88ab\u88c1\u5207\u7684\u5927\u56fe            \/\/\u521b\u5efa\u7f29\u7565\u56fe            if ($type != 'gif' && function_exists('imagecreatetruecolor'))                $thumbImg = imagecreatetruecolor($maxWidth, $maxHeight);            else                $thumbImg = imagecreate($maxWidth, $maxHeight);\/\/\u751f\u6210\u7684\u5c0f\u56fe            \/\/ \u590d\u5236\u56fe\u7247            if (function_exists("ImageCopyResampled"))                imagecopyresampled($thumbImg, $srcImg, 0, 0, $x,$y,$maxWidth, $maxHeight, $selectWidth, $selectHeight);            else                imagecopyresized($thumbImg, $srcImg, 0, 0, $x, $y, $maxWidth, $maxHeight, $selectWidth, $selectHeight);            if ('gif' == $type || 'png' == $type) {                \/\/imagealphablending($thumbImg, false);\/\/\u53d6\u6d88\u9ed8\u8ba4\u7684\u6df7\u8272\u6a21\u5f0f                \/\/imagesavealpha($thumbImg,true);\/\/\u8bbe\u5b9a\u4fdd\u5b58\u5b8c\u6574\u7684 alpha \u901a\u9053\u4fe1\u606f                $background_color = imagecolorallocate($thumbImg, 0, 255, 0);  \/\/  \u6307\u6d3e\u4e00\u4e2a\u7eff\u8272                imagecolortransparent($thumbImg, $background_color);  \/\/  \u8bbe\u7f6e\u4e3a\u900f\u660e\u8272\uff0c\u82e5\u6ce8\u91ca\u6389\u8be5\u884c\u5219\u8f93\u51fa\u7eff\u8272\u7684\u56fe            }            \/\/ \u5bf9jpeg\u56fe\u5f62\u8bbe\u7f6e\u9694\u884c\u626b\u63cf            if ('jpg' == $type || 'jpeg' == $type)                imageinterlace($thumbImg, $interlace);            \/\/ \u751f\u6210\u56fe\u7247            $imageFun = 'image' . ($type == 'jpg' ? 'jpeg' : $type);            $imageFun($thumbImg, $thumbname);            imagedestroy($thumbImg);            imagedestroy($srcImg);            return $thumbname;        }        return false;}<\/p>

<\/p>

<\/p>"}