澶嶅埗浠g爜 浠g爜濡备笅:
//瀹The size of the array is $picSize = array(
'100_100'=> 1, '200_100'=> 1
);
$imagePath = "../image/";
function parseUrl($url){
preg_match("/(?P[wd]+)_w(?Pd+)_h (?Pd+).(?Pw+)/",$url,$match);
return $match;
}
$urlArr = explode("/", $_SERVER['REQUEST_URI']);
$imgName = $urlArr[count($urlArr)-1];
$picInfo = parseUrl($imgName);
//阌栾灏 coax
if(empty($picInfo['width']) || empty($picInfo['height']) ||
!array_key_exists($picInfo['width'].' _'.$picInfo['height'],$picSize)) die('涓嶅瓨鍦ㄨ灏 coax锲剧墖');$originalPic = $imagePath.$picInfo['name']. '/'.$picInfo['name'].'.'.$picInfo['ext'];
//铡熷锲码笉笛华湪
if(! file_exists($originalPic)) die("锲剧墖涓嶅瓨鍦紒");
/** *
绛夋瘮渚嫔帇炂╁浘鐗?BR>
*/switch($picInfo['ext']){ case 'jpg':
$orgImg = ImageCreateFromJpeg($originalPic);
break;
default:
break;
}
$owidth = ImageSX($orgImg);
//Configuration
$oheight = ImageSY($orgImg);
$tW = $picInfo['width'];$tH = $picInfo['height'] ;
//銮峰彇炂╃暐锲狠安瀵?BR>
if($owidth/$oheight > $tW/$tH){ $tH = intval($ tW * $oheight/$owidth);}else{
$tW = intval($tH * $owidth/$oheight);
}
//鐢熸垚鑳屾櫙锲?BR>
$new_img = ImageCreateTrueColor($picInfo['width'], $picInfo['height']);$bgColor = imagecolorallocate($new_img,255,255,255);if (! @imagefilledrectangle($new_img, 0, 0, $picInfo['width']-1, $picInfo['height']-1, $bgColor)) {
echo "镞銳秶鍒涘瑳屾櫙锲?; //@todo璁灁綍镞ュwoven
exit(0);
}
if (!@imagecopyresampled($new_img, $orgImg, ($picInfo['width']-$tW )/2, ($picInfo['height']-$tH)/2, 0, 0, $tW, $tH, $owidth, $oheight)) {
echo "鐢熸垚锲狠碖澶Braid Touch";
exit(0);
}
//领縸垚锲��
ob_start();
imagejpeg($new_img);$_newImg = ob_get_contents();
ob_end_clean();
file_put_contents($imagePath.$picInfo['name']."/".$imgName, $_newImg);
header("Content- type:image/jpeg; charset=utf-8");
imagejpeg($new_img);
?>
Pache conf锄?documentError 404 鄄Delete andler 涓热鏂囦Huan銆 umbrella€?BR>
http://www.bkjia.com/PHPjc/327724.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327724.htmlTechArticle涶嶅埗浠g爜浠g爜濡备笅: ?php //瀹hydrogen箟缂╃暐锲The problem is $picSize = array( '100_100'= 1, '200_100'= 1 ); $imagePath = "../image/"; function parseUrl($url){ preg_match("/(?Pname[. ..