썸네일 이미지가 원본이미지에서 짤려서 나옵니다.. 정보
썸네일 이미지가 원본이미지에서 짤려서 나옵니다..본문
<? // 리스트화면-섬네일 (첫번째 파일이미지)
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
if ($_FILES[bf_file][name][0])
{
$row = sql_fetch(" select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '0' ");
$file = $data_path .'/'. $row[bf_file];
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $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
break;
$rate = $board[bo_1] / $size[0];
$height = (int)($size[1] * $rate);
//@unlink($thumb_path.'/'.$wr_id);
//$dst = imagecreatetruecolor($board[bo_1], $height);
//imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_1], $height, $size[0], $size[1]);
//imagepng($dst, $thumb_path.'/'.$wr_id, $board[bo_2]);
//chmod($thumb_path.'/'.$wr_id, 0606);
// 설정된 이미지 높이로 복사본 이미지 생성
$img_width = '181'; //썸네일 가로길이
$img_height = '79'; //썸네일 세로길이
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$wr_id, $img_height);
chmod($thumb_path.'/'.$wr_id, 0606);
}
}
?>
글쓰기 부분에 이렇게 되어 있는데요 올리면 원본 이미지에서 181,79 사이즈로 짤려서 썸네일이 출력 됩니다. 짤리는거 말고 원본이미지를 축소 시킬 방법 좀 알려 주세요.. 부탁드립니다..
댓글 전체
예)
120
120
90
그리고 위 소스 $rate 부분부터 아래 소스로 수정해 보세요..
$rate = $board[bo_2] / $size[1];
$width = (int)($size[0] * $rate);
//echo "rate : $rate ,width : $width, $height : $board[bo_2] <br>";
if($width <= $board[bo_1]) { //width가 지정된 사이즈보다 작을경우 rate 비율로 썸네일 생성
$dst = imagecreatetruecolor($width, $board[bo_2]);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $board[bo_2], $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $board[bo_3]);
} else {
$rate = $board[bo_1] / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($board[bo_1], $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $board[bo_1], $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $board[bo_3]);
}
}
}
을 imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $img_height, $size[0], $size[1]); 로바꾸니까 잘되고 있습니다 답글 감사드립니다. ^^