썸네일 생성

링크를 참조하면 어떠한 코드인지 알 수 있을 것 같습니다.
 
board_file 테이블에 파일이 없을 경우 다른 이미지로 교체 하였으면 하는데~
 
어떻게 하면 될까요...?
 
 
 
<?
for ($i=0; $i<count($list); $i++)
{
$data_path = $g4['path'] . "/data/file/{$list[$i][bo_table]}";//라이브러리 파일 참조
$thumb_path = $data_path . '/thumb100';
if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
    $filename = $list[$i]['bf_file']; //원본파일명
    $thumb = $thumb_path.'/'.$filename; //썸네일파일명
    if (!file_exists($thumb))
    {
 $file = $data_path.'/'.$filename; //원본파일명의 경로 g4_board_file_table
        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 = 100 / $size[0];
            $height = (int)($size[1] * $rate);
            if ($height < 75)
                $dst = imagecreatetruecolor(100, $height);
            else
                $dst = imagecreatetruecolor(100, 75);
            imagecopyresampled($dst, $src, 0, 0, 0, 0, 100, $height, $size[0], $size[1]);
            imagejpeg($dst, $thumb_path.'/'.$filename, 100);
            chmod($thumb_path.'/'.$filename, 0707);
        }
    }
    if (file_exists($thumb)) {
        $img = "<img src='$thumb' border=0>";
    }
}
?>
|

댓글 3개

아래쪽 소스에서


if (file_exists($thumb)) {
$img = "<img src='$thumb' border=0>";
}




if (file_exists($thumb)) {
$img = "<img src='$thumb' border=0>";
} else {
$img = "<img src='노이미지 주소' border=0>";
}
이미 위 방법은 시도 하였으나 안 됩니다~ ^ ^,,
해결했습니다. ^ ^;;

관심을 갖어준 열매님 고맙습니다. ^ ^!
댓글을 작성하시려면 로그인이 필요합니다. 로그인

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
19년 전 조회 1,415
19년 전 조회 1,201
19년 전 조회 1,403
19년 전 조회 1,605
19년 전 조회 1,431
19년 전 조회 1,632
19년 전 조회 1,234
19년 전 조회 1,432
19년 전 조회 1,645
19년 전 조회 1,550
19년 전 조회 1,585
19년 전 조회 1,318
19년 전 조회 1,825
19년 전 조회 1,568
19년 전 조회 1,624
19년 전 조회 1,473
19년 전 조회 1,989
19년 전 조회 1,175
19년 전 조회 964
19년 전 조회 1,520
🐛 버그신고