澶嶅埗浠g爜浠g爜濡备笅:
//瀹水素箟缂╃暐ストーリー墖灏描
$ picSize = array(
' [ wd]+)_w(?Pd+)_h(?Pd+).(?Pw+)/",$url,$match);
return $match;
}
$ urlArr =explode("/",$_SERVER['REQUEST_URI']);
$imgName = $urlArr[count($urlArr)-1];
$picInfo = parseUrl($imgName);
//阌栾 If(empty($picInfo['width']) || empty($picInfo['height']) ||
!array_key_exists($picInfo['width'].'_'.$picInfo[ 'height'], $picSize)) die('涓嶅稨鍦ㄨ皏珏锲story墖');
$originalPic = $imagePath.$picInfo['名前'].'/'.$picInfo['名前'].' .'.$picInfo['ext'];
//铡熷锲码笉盛华湪
if(!file_exists($originalPic)) die("锲story墖涓嶅瓨鍦紒"); /**
*
绛夋瘮渚帇缂╁浘鐗?BR>
*/switch($picInfo['ext']){
case 'jpg': $orgImg = ImageCreateFromJpeg($originalPic);
ブレーク;
デフォルト: ブレーク ;}
$ owidth = ImageSX($orgImg);
//結論: $oheight = ImageSY($orgImg);
$tW = $picInfo['width'];
$tH = $ picinfo ['height']; //銮 彇缂 彇缂 ╃ ╃ 瀵 瀵 瀵? Br>
IF ($ OWIDTH/$ oheight & gt; $ 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璁板綍镞布 exit(0);
}
if (!@imagecopyresampled($new_img) 、$orgImg、($picInfo['width']-$tW)/2、($picInfo['height']-$tH)/2、0、0、$tW、$tH、$owidth、$oheight) ) {
echo "鐢瞸垚锲综合墖澶三つ編みタッチ";
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);
?>
邂妦愿犆傘€?BR>
http://www.bkjia.com/PHPjc/327724.html
www.bkjia.com
true
http://www.bkjia.com/PHPjc/327724.html
技術記事
$picSize = array( '100_100'= 1, '200_100'= 1 ); $imagePath = "../image/" function parseUrl($url){ preg_match("/(?Pname[...)