function img_resize_only($path, $img, $maxwidth, $maxheight) {
if($img) {
// $img는 이미지의 경로(예:./images/phplove.gif)
$imgsize = getimagesize($path.$img);
if($imgsize[0]>$maxwidth || $imgsize[1]>$maxheight) {
// 가로길이가 가로limit값보다 크거나 세로길이가 세로limit보다 클경우
$sumw = (100*$maxheight)/$imgsize[1];
$sumh = (100*$maxwidth)/$imgsize[0];
if($sumw < $sumh) {
// 가로가 세로보다 클경우
$img_width = ceil(($imgsize[0]*$sumw)/100);
$img_height = $maxheight;
} else {
// 세로가 가로보다 클경우
$img_height = ceil(($imgsize[1]*$sumh)/100);
$img_width = $maxwidth;
}
} else {
// limit보다 크지 않는 경우는 원본 사이즈 그대로.....
$img_width = $imgsize[0];
$img_height = $imgsize[1];
}
$imgsize[0] = $img_width;
$imgsize[1] = $img_height;
} else {
$imgsize[0] = $maxwidth;
$imgsize[1] = $maxheight;
}
return $imgsize;
}
출처는 : http://blog.voidcat.co.cc/index.php?mid=blog&document_srl=463&search_target=tag&search_keyword=PHP
입니다.




최근 덧글