썸네일 이미지 세로비율 유지하는 법 좀 가르쳐 주십시오. 정보
썸네일 이미지 세로비율 유지하는 법 좀 가르쳐 주십시오.본문
맛집소개 스킨을 사용하고 있는데요
view.skin.php에서 horizontal_view.php를 불러와서 사용하고 있습니다.
이미지를 여러개 첨부하면 작은 썸네일이 나오고, 작은썸네일에 마우스를 올리면 큰이미지가 보이는 소스입니다.
그런데
가로가 긴 이미지를 넣으면 정상적으로 나오는데요
세로가 긴 이미지를 넣으면 찌그러져서 나옵니다.
어떤이미지를 넣어도 비율대로 보여주는 소스는 없을까요?
사용자들이 올리는 사진은 가지각색일텐데...ㅜㅜ
아래 horizontal_view.php 소스를 올립니다.
아시는 분들의 도움을 부탁드립니다.
감사합니다.
-------------------------horizontal_view.php 소스-------------------------------------
<?
function UnsharpMask($img, $amount, $radius, $threshold) {
// Attempt to calibrate the parameters to Photoshop:
if ($amount > 500) $amount = 500;
$amount = $amount * 0.016;
if ($radius > 50) $radius = 50;
$radius = $radius * 2;
if ($threshold > 255) $threshold = 255;
$radius = abs(round($radius)); // Only integers make sense.
if ($radius == 0) { return $img; imagedestroy($img); break; }
$w = imagesx($img); $h = imagesy($img);
$imgCanvas = $img;
$imgCanvas2 = $img;
$imgBlur = imagecreatetruecolor($w, $h);
// Gaussian blur matrix:
// 1 2 1
// 2 4 2
// 1 2 1
// Move copies of the image around one pixel at the time and merge them with weight
// according to the matrix. The same matrix is simply repeated for higher radii.
for ($i = 0; $i < $radius; $i++)
{
imagecopy ($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left
imagecopymerge ($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right
imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left
imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right
imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left
imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right
imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up
imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down
imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center
}
$imgCanvas = $imgBlur;
// Calculate the difference between the blurred pixels and the original
// and set the pixels
for ($x = 0; $x < $w; $x++)
{ // each row
for ($y = 0; $y < $h; $y++)
{ // each pixel
$rgbOrig = ImageColorAt($imgCanvas2, $x, $y);
$rOrig = (($rgbOrig >> 16) & 0xFF);
$gOrig = (($rgbOrig >> 8) & 0xFF);
$bOrig = ($rgbOrig & 0xFF);
$rgbBlur = ImageColorAt($imgCanvas, $x, $y);
$rBlur = (($rgbBlur >> 16) & 0xFF);
$gBlur = (($rgbBlur >> 8) & 0xFF);
$bBlur = ($rgbBlur & 0xFF);
// When the masked pixels differ less from the original
// than the threshold specifies, they are set to their original value.
$rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig;
$gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig;
$bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig;
if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew))
{
$pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
ImageSetPixel($img, $x, $y, $pixCol);
}
}
}
return $img;
}
?>
<?
//썸네일 코드 시작
$data_path = $g4['path'] . "/data/file/{$bo_table}";//라이브러리 파일 참조
$thumb_path = $data_path . '/thumbOpen';
$thumb_path2 = $data_path . '/thumbOpen2';
?>
<SCRIPT LANGUAGE='JavaScript'>
// 이미지뷰어
<!--
var win= null;
function View_Open(img, w, h)
{
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/3;
var settings ='height='+h+',';
settings +='width='+w+',';
settings +='top='+wint+',';
settings +='left='+winl+',';
settings +='scrollbars=yes,';
settings +='resizable=yes,';
settings +='status=no';
win=window.open("","newWindow",settings);
win.document.open();
win.document.write ("<html><head><title>원본 이미지 보기</title></head>");
win.document.write ("<script>function init(){window.resizeBy(document.all.pop_img.width-document.body.clientWidth, document.all.pop_img.height-document.body.clientHeight+10);}</script>");
win.document.write ("<body bgcolor=white topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 oncontextmenu='return false' ondragstart='return false' onkeydown='return false' onselectstart='return false' onload='init();'>");
win.document.write ("<img src='"+img+"' border=0 onclick='window.close();' style='cursor:hand' title='클릭하면 닫혀요' id='pop_img'>");
win.document.write ("</body></html>");
win.document.close();
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
image_directory = ""; //배경이미지 경로
clear = new Image(); clear.src = image_directory + "./img/blank.gif";
<?
//파일 뽑기
$sql2 = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 12 ";
$result2 = sql_query($sql2);
for ($j=0; $row2 = sql_fetch_array($result2); $j++) {
if($j==0) $view_one = "{$thumb_path2}/{$row2['bf_file']}";
}
?>
// -->
</SCRIPT>
<table cellspacing="0" cellpadding="0" border="0" align="left">
<tr height="5">
<td colspan="5"></td>
</tr>
<tr>
<td style="border:10px solid #000000;" width="580" height="400" align="center" valign="top" bgcolor=#ffffff>
<div style='width:580px;position:relative; ' align="center" id="loadarea"><img src="<?=$view_one?>" border="0"></div>
</td>
</tr>
<tr>
<!--작은사진목록-->
<td bgcolor="#000000" style="padding:4 0 4 0px;" width="580" height="110%" align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" valign='top'>
<tr>
<td style="border:solid 1px #D3D3D3; background-color:#E5E5E5; " valign='top'>
<tr>
<?
//파일 뽑기
$sql = " select bf_file, bf_source from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 12 ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
if($i != 0 && $i % 6 == 0) echo "</tr><tr><td colspan='3' style='height:7px;'></td></tr><tr>";
if($i % 6 != 0) echo "<td width=10></td>";
$view_w = 580; //썸네일 가로사이즈
$view_h = 400; //썸네일 세로사이즈
$sch_q = 100; //썸네일 퀼리티
if (!is_dir($thumb_path2)) {
@mkdir($thumb_path2, 0707);
@chmod($thumb_path2, 0707);
}
if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
$filename = $row[bf_file]; //파일명
$thumb2 = $thumb_path2.'/'.$filename; //썸네일
if (!file_exists($thumb2)) { //view 용 이미지 생성
$file = $data_path.'/'.$filename; //원본
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
continue;
$rate = $view_h / $size[1];
//$width = (int)($size[0] * $rate);
$width = 580; //가로 사이즈 고정
//echo "rate : $rate ,width : $width, $height : $board[bo_2] <br>";
if($width <= $view_w) { //width가 지정된 사이즈보다 작을경우 rate 비율로 썸네일 생성
$dst = imagecreatetruecolor($width, $view_h);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $view_h, $size[0], $size[1]);
imagepng($dst, $thumb_path2.'/'.$filename, $sch_q);
} else {
$rate = $view_w / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($view_w, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $view_w, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path2.'/'.$filename, $sch_q);
}
chmod($thumb_path2.'/'.$filename, 0707);
}
}
$view_w = 66; //썸네일 가로사이즈
$view_h = 44; //썸네일 세로사이즈
$thumb = $thumb_path.'/'.$filename; //썸네일
if (!file_exists($thumb)) { //기본 썸네일
$file = $data_path.'/'.$filename; //원본
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
continue;
$rate = $view_h / $size[1];
//$width = (int)($size[0] * $rate);
$width = 66;
//echo "rate : $rate ,width : $width, $height : $board[bo_2] <br>";
if($width <= $view_w) { //width가 지정된 사이즈보다 작을경우 rate 비율로 썸네일 생성
$dst = imagecreatetruecolor($width, $view_h);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $view_h, $size[0], $size[1]);
$dst = UnsharpMask($dst, 80, 0.5, 3);
imagepng($dst, $thumb_path.'/'.$filename, $sch_q);
} else {
$rate = $view_w / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($view_w, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $view_w, $height, $size[0], $size[1]);
$dst = UnsharpMask($dst, 80, 0.5, 3);
imagepng($dst, $thumb_path.'/'.$filename, $sch_q);
}
chmod($thumb_path.'/'.$filename, 0707);
}
}
if (file_exists($thumb) && $filename) {
?>
<td style="border:solid 0px #D0D0D0;height:44px;width:66px;" align='left' width=88 height=66>
<a rel="enlargeimage::mouseover" rev="loadarea" href="<?=$thumb_path2?>/<?=$filename?>"><img src="<?=$thumb?>" style="border-width:0px;" /></a>
</td>
<?
//onMouseOut="bgChange('clear');"
}
}
?>
<? for($c = 0; $c < (6 - ($i-1 % 6)); $c ++) echo "<td width=10></td><td width=88 height=66></td>"; ?>
</tr>
</table>
</td>
</tr>
</table>
<!--작은사진목록-->
view.skin.php에서 horizontal_view.php를 불러와서 사용하고 있습니다.
이미지를 여러개 첨부하면 작은 썸네일이 나오고, 작은썸네일에 마우스를 올리면 큰이미지가 보이는 소스입니다.
그런데
가로가 긴 이미지를 넣으면 정상적으로 나오는데요
세로가 긴 이미지를 넣으면 찌그러져서 나옵니다.
어떤이미지를 넣어도 비율대로 보여주는 소스는 없을까요?
사용자들이 올리는 사진은 가지각색일텐데...ㅜㅜ
아래 horizontal_view.php 소스를 올립니다.
아시는 분들의 도움을 부탁드립니다.
감사합니다.
-------------------------horizontal_view.php 소스-------------------------------------
<?
function UnsharpMask($img, $amount, $radius, $threshold) {
// Attempt to calibrate the parameters to Photoshop:
if ($amount > 500) $amount = 500;
$amount = $amount * 0.016;
if ($radius > 50) $radius = 50;
$radius = $radius * 2;
if ($threshold > 255) $threshold = 255;
$radius = abs(round($radius)); // Only integers make sense.
if ($radius == 0) { return $img; imagedestroy($img); break; }
$w = imagesx($img); $h = imagesy($img);
$imgCanvas = $img;
$imgCanvas2 = $img;
$imgBlur = imagecreatetruecolor($w, $h);
// Gaussian blur matrix:
// 1 2 1
// 2 4 2
// 1 2 1
// Move copies of the image around one pixel at the time and merge them with weight
// according to the matrix. The same matrix is simply repeated for higher radii.
for ($i = 0; $i < $radius; $i++)
{
imagecopy ($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left
imagecopymerge ($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right
imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left
imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right
imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left
imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right
imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up
imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down
imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center
}
$imgCanvas = $imgBlur;
// Calculate the difference between the blurred pixels and the original
// and set the pixels
for ($x = 0; $x < $w; $x++)
{ // each row
for ($y = 0; $y < $h; $y++)
{ // each pixel
$rgbOrig = ImageColorAt($imgCanvas2, $x, $y);
$rOrig = (($rgbOrig >> 16) & 0xFF);
$gOrig = (($rgbOrig >> 8) & 0xFF);
$bOrig = ($rgbOrig & 0xFF);
$rgbBlur = ImageColorAt($imgCanvas, $x, $y);
$rBlur = (($rgbBlur >> 16) & 0xFF);
$gBlur = (($rgbBlur >> 8) & 0xFF);
$bBlur = ($rgbBlur & 0xFF);
// When the masked pixels differ less from the original
// than the threshold specifies, they are set to their original value.
$rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig;
$gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig;
$bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig;
if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew))
{
$pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
ImageSetPixel($img, $x, $y, $pixCol);
}
}
}
return $img;
}
?>
<?
//썸네일 코드 시작
$data_path = $g4['path'] . "/data/file/{$bo_table}";//라이브러리 파일 참조
$thumb_path = $data_path . '/thumbOpen';
$thumb_path2 = $data_path . '/thumbOpen2';
?>
<SCRIPT LANGUAGE='JavaScript'>
// 이미지뷰어
<!--
var win= null;
function View_Open(img, w, h)
{
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/3;
var settings ='height='+h+',';
settings +='width='+w+',';
settings +='top='+wint+',';
settings +='left='+winl+',';
settings +='scrollbars=yes,';
settings +='resizable=yes,';
settings +='status=no';
win=window.open("","newWindow",settings);
win.document.open();
win.document.write ("<html><head><title>원본 이미지 보기</title></head>");
win.document.write ("<script>function init(){window.resizeBy(document.all.pop_img.width-document.body.clientWidth, document.all.pop_img.height-document.body.clientHeight+10);}</script>");
win.document.write ("<body bgcolor=white topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 oncontextmenu='return false' ondragstart='return false' onkeydown='return false' onselectstart='return false' onload='init();'>");
win.document.write ("<img src='"+img+"' border=0 onclick='window.close();' style='cursor:hand' title='클릭하면 닫혀요' id='pop_img'>");
win.document.write ("</body></html>");
win.document.close();
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
image_directory = ""; //배경이미지 경로
clear = new Image(); clear.src = image_directory + "./img/blank.gif";
<?
//파일 뽑기
$sql2 = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 12 ";
$result2 = sql_query($sql2);
for ($j=0; $row2 = sql_fetch_array($result2); $j++) {
if($j==0) $view_one = "{$thumb_path2}/{$row2['bf_file']}";
}
?>
// -->
</SCRIPT>
<table cellspacing="0" cellpadding="0" border="0" align="left">
<tr height="5">
<td colspan="5"></td>
</tr>
<tr>
<td style="border:10px solid #000000;" width="580" height="400" align="center" valign="top" bgcolor=#ffffff>
<div style='width:580px;position:relative; ' align="center" id="loadarea"><img src="<?=$view_one?>" border="0"></div>
</td>
</tr>
<tr>
<!--작은사진목록-->
<td bgcolor="#000000" style="padding:4 0 4 0px;" width="580" height="110%" align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" valign='top'>
<tr>
<td style="border:solid 1px #D3D3D3; background-color:#E5E5E5; " valign='top'>
<tr>
<?
//파일 뽑기
$sql = " select bf_file, bf_source from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 12 ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
if($i != 0 && $i % 6 == 0) echo "</tr><tr><td colspan='3' style='height:7px;'></td></tr><tr>";
if($i % 6 != 0) echo "<td width=10></td>";
$view_w = 580; //썸네일 가로사이즈
$view_h = 400; //썸네일 세로사이즈
$sch_q = 100; //썸네일 퀼리티
if (!is_dir($thumb_path2)) {
@mkdir($thumb_path2, 0707);
@chmod($thumb_path2, 0707);
}
if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
$filename = $row[bf_file]; //파일명
$thumb2 = $thumb_path2.'/'.$filename; //썸네일
if (!file_exists($thumb2)) { //view 용 이미지 생성
$file = $data_path.'/'.$filename; //원본
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
continue;
$rate = $view_h / $size[1];
//$width = (int)($size[0] * $rate);
$width = 580; //가로 사이즈 고정
//echo "rate : $rate ,width : $width, $height : $board[bo_2] <br>";
if($width <= $view_w) { //width가 지정된 사이즈보다 작을경우 rate 비율로 썸네일 생성
$dst = imagecreatetruecolor($width, $view_h);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $view_h, $size[0], $size[1]);
imagepng($dst, $thumb_path2.'/'.$filename, $sch_q);
} else {
$rate = $view_w / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($view_w, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $view_w, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path2.'/'.$filename, $sch_q);
}
chmod($thumb_path2.'/'.$filename, 0707);
}
}
$view_w = 66; //썸네일 가로사이즈
$view_h = 44; //썸네일 세로사이즈
$thumb = $thumb_path.'/'.$filename; //썸네일
if (!file_exists($thumb)) { //기본 썸네일
$file = $data_path.'/'.$filename; //원본
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file)) {
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
continue;
$rate = $view_h / $size[1];
//$width = (int)($size[0] * $rate);
$width = 66;
//echo "rate : $rate ,width : $width, $height : $board[bo_2] <br>";
if($width <= $view_w) { //width가 지정된 사이즈보다 작을경우 rate 비율로 썸네일 생성
$dst = imagecreatetruecolor($width, $view_h);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $view_h, $size[0], $size[1]);
$dst = UnsharpMask($dst, 80, 0.5, 3);
imagepng($dst, $thumb_path.'/'.$filename, $sch_q);
} else {
$rate = $view_w / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($view_w, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $view_w, $height, $size[0], $size[1]);
$dst = UnsharpMask($dst, 80, 0.5, 3);
imagepng($dst, $thumb_path.'/'.$filename, $sch_q);
}
chmod($thumb_path.'/'.$filename, 0707);
}
}
if (file_exists($thumb) && $filename) {
?>
<td style="border:solid 0px #D0D0D0;height:44px;width:66px;" align='left' width=88 height=66>
<a rel="enlargeimage::mouseover" rev="loadarea" href="<?=$thumb_path2?>/<?=$filename?>"><img src="<?=$thumb?>" style="border-width:0px;" /></a>
</td>
<?
//onMouseOut="bgChange('clear');"
}
}
?>
<? for($c = 0; $c < (6 - ($i-1 % 6)); $c ++) echo "<td width=10></td><td width=88 height=66></td>"; ?>
</tr>
</table>
</td>
</tr>
</table>
<!--작은사진목록-->
댓글 전체
가로든 세로든 큰쪽 사이즈를 일정하게 유지하면서 나머지는 비율대로 줄이는 방법입니다.
$board[bo_1]에 기준 크기를 입력했을때입니다.
if (preg_match("/\.($config[cf_image_extension])$/i", $file[$i][file]))
{
$size = getimagesize($file_path);
//가로,세로 최대사이즈 제한, Daeng`2님 팁
if ($size[0] >= $size[1])//가로가 클때
{
$rate = $board[bo_1] / $size[0];
$width = $board[bo_1];
$height = (int)($size[1] * $rate);
}
else
{
$rate = $board[bo_1] / $size[1];
$width = (int)($size[0] * $rate);
$height = $board[bo_1];
}
}
$board[bo_1]에 기준 크기를 입력했을때입니다.
if (preg_match("/\.($config[cf_image_extension])$/i", $file[$i][file]))
{
$size = getimagesize($file_path);
//가로,세로 최대사이즈 제한, Daeng`2님 팁
if ($size[0] >= $size[1])//가로가 클때
{
$rate = $board[bo_1] / $size[0];
$width = $board[bo_1];
$height = (int)($size[1] * $rate);
}
else
{
$rate = $board[bo_1] / $size[1];
$width = (int)($size[0] * $rate);
$height = $board[bo_1];
}
}