Home > Backend Development > PHP Tutorial > PHP chain link

PHP chain link

WBOY
Release: 2016-07-21 15:05:16
Original
1283 people have browsed it

澶嶅埗浠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

truehttp: //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[. ..
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template