이미지 자동으로 줄여주기...
본문
아래 소스는 그누보드4에서 적용하던 건데요.
갤러리 게시판에서 이미지를 자동으로 줄여주던 소스에요.(write_update.skin.php)
당연히 그누보드5에서는 수정을 해서 써야 겠지요?
잘안되네요! 고수님들의 조언 부탁드립니다.
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path;
$img_width = 727; //새로 만드는 이미지 사이즈
$sql2=" select * from $G5_PATH[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no asc";
$results2 = sql_query($sql2);
for ($d=0; $row2=sql_fetch_array($results2); $d++) {
if ($_FILES[bf_file][name][$d])
{
$file = $data_path .'/'. $row2[bf_file];
$IMG_info = getimagesize ($file);
$thum_W = $IMG_info[0] ;
if ($thum_W > $img_width) {
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 = $img_width / $size[0];
$height = (int)($size[1] * $rate);
@unlink($data_path.'/'.$row2[bf_file]);
$dst = imagecreatetruecolor($img_width, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $data_path.'/'.$row2[bf_file], $board[bo_2]);
//imagepng($dst, $data_path.'/'.$row2[bf_file], $board[bo_2]); //주석 해제
chmod($data_path.'/'.$row2[bf_file], 0606);
} // 네번째 그림형식확인
} //세번째 그림크기확인
} // 두번째 if
} //첫번째 for
?>
답변 1
$data_path = G5_PATH."/data/file/$bo_table";
$thumb_path = $data_path;
$img_width = 727; //새로 만드는 이미지 사이즈
$sql2=" select * from $g5[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no asc";