썸네일 생성 정보
썸네일 생성
관련링크
본문
링크를 참조하면 어떠한 코드인지 알 수 있을 것 같습니다.
board_file 테이블에 파일이 없을 경우 다른 이미지로 교체 하였으면 하는데~
어떻게 하면 될까요...?
<?
for ($i=0; $i<count($list); $i++)
{
$data_path = $g4['path'] . "/data/file/{$list[$i][bo_table]}";//라이브러리 파일 참조
$thumb_path = $data_path . '/thumb100';
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);
}
@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;
$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);
$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);
}
}
$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>";
}
$img = "<img src='$thumb' border=0>";
}
}
?>
댓글 전체
아래쪽 소스에서
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>";
}
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>";
}
이미 위 방법은 시도 하였으나 안 됩니다~ ^ ^,,
해결했습니다. ^ ^;;
관심을 갖어준 열매님 고맙습니다. ^ ^!
관심을 갖어준 열매님 고맙습니다. ^ ^!