이미지 리사이징 resizing > Board Tip

본문 바로가기
 

이미지 리사이징 resizing

페이지 정보

작성자 휴먼 댓글 0건 조회 6,421회 작성일 09-11-01 18:39

본문


// 첨부 이미지 리사이징, 아래 보드는 제외함(원size대로).
// write_update.skin.php에 아래와 같이 하니 잘되는군요....

if ($bo_table != "aaaa" && $bo_table != "bbbb" ) {
$img_limit_width = 800; // 제한할 이미지 폭
$img_quality = 100; // 이미지 품질
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
    $sql2=" select * from $g4[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];
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_limit_width / $size[0];
$height = (int)($size[1] * $rate);
if ($size[0] > $img_limit_width){
@unlink($data_path.'/'.$row2[bf_file]);
$dst = imagecreatetruecolor($img_limit_width, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_limit_width, $height, $size[0], $size[1]);
// imagepng($dst, $data_path.'/'.$row2[bf_file], $board[bo_2]);
//이부분이 png 압축방식이어서 이미지 커졌나 봅니다.
//아래처럼 하니 줄어드는 것을 확실히 느껴집니다....^^   
imagejpeg($dst, $data_path.'/'.$row2[bf_file], $img_quality);
chmod($data_path.'/'.$row2[bf_file], 0606);
//---------->madem님이 알려주신 부분입니다.^^
$bf_size = @filesize(addslashes($file));
$sql = " update $g4[board_file_table]
set bf_filesize = '$bf_size'
where  bo_table = '$bo_table' and wr_id = '$wr_id'  ";
sql_query($sql);
 //---------->madem님이 알려주신 부분입니다.^^
 }
 }
 }
 }
}

댓글목록

등록된 댓글이 없습니다.

Total 59건 2 페이지
게시물 검색