썸네일 이미지 생성 관련하여 질문을 올려봅니다. 정보
썸네일 이미지 생성 관련하여 질문을 올려봅니다.본문
안녕하세요. 첫페이지에 게시판의 이미지를 하나 불러오려고 합니다.
그냥 불러오는 것이 아니라 썸네일 이미지를 생성하여 그것을 불러오려고 하는데 아래와 같이 소스를 조합하여 해보았습니다. 그런데 안되더라구요.. 이미지가 뜨질 않아요.. ftp로 확인을 해보니 폴더는 생성이 되는데 썸네일 이미지가 생성이 안되어 엑박이미지가 뜹니다.
고수님들의 가르침 부탁드립니다.
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<table width=100% cellpadding=0 cellspacing=0 >
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<table width=100% cellpadding=0 cellspacing=0 >
<? for ($i=0; $i<count($list); $i++) {$m++;
$data_path = $g4[path]."/data/file/{$list[$i][bo_table]}";
$thumb_path = $data_path.'/thumb_x';
$thumb_path = $data_path.'/thumb_x';
$thumb_size = 300;
$thumb_quality = 80;
$thumb_quality = 80;
if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
$gr_subject = cut_str($list[$i][gr_subject], 10);
$bo_subject = cut_str($list[$i][bo_subject], 12, "");
$wr_subject = cut_str($list[$i][wr_subject], $subject_len,"");
?>
<tr>
<td align=center>
<table width=100% valign=top border=0 cellpadding=0 cellspacing=0>
<tr>
<td align="center">
$bo_subject = cut_str($list[$i][bo_subject], 12, "");
$wr_subject = cut_str($list[$i][wr_subject], $subject_len,"");
?>
<tr>
<td align=center>
<table width=100% valign=top border=0 cellpadding=0 cellspacing=0>
<tr>
<td align="center">
<?
$filename = $list[$i]['bf_file'];
$dest_file = $data_path .'/'. $filename;
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $filename) && file_exists($dest_file)){
//$thumb = "$thumb_path/".urlencode($row3['bf_file']);//공백문자 변형(+, %2B) 파일명으로 생성됨
$thumb = $thumb_path . '/' . $filename;
$filename = $list[$i]['bf_file'];
$dest_file = $data_path .'/'. $filename;
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $filename) && file_exists($dest_file)){
//$thumb = "$thumb_path/".urlencode($row3['bf_file']);//공백문자 변형(+, %2B) 파일명으로 생성됨
$thumb = $thumb_path . '/' . $filename;
if (!file_exists($thumb)) {
$size = getimagesize($dest_file);
if ($size[2] == 1)
$src = imagecreatefromgif($dest_file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($dest_file);
else if ($size[2] == 3)
$src = imagecreatefrompng($dest_file);
else
break;
//가로,세로 최대사이즈 제한,
if ($size[0] >= $size[1]) {
$rate = $thumb_size / $size[0];
$width = $thumb_size;
$height = (int)($size[1] * $rate);
}
else {
$rate = $thumb_size / $size[1];
$width = (int)($size[0] * $rate);
$height = $thumb_size;
}
$dst = imagecreatetruecolor($width, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
imagepng($dst, $thumb, $thumb_quality);
chmod($thumb, 0707);
}
if ($size[2] == 1)
$src = imagecreatefromgif($dest_file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($dest_file);
else if ($size[2] == 3)
$src = imagecreatefrompng($dest_file);
else
break;
//가로,세로 최대사이즈 제한,
if ($size[0] >= $size[1]) {
$rate = $thumb_size / $size[0];
$width = $thumb_size;
$height = (int)($size[1] * $rate);
}
else {
$rate = $thumb_size / $size[1];
$width = (int)($size[0] * $rate);
$height = $thumb_size;
}
$dst = imagecreatetruecolor($width, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
imagepng($dst, $thumb, $thumb_quality);
chmod($thumb, 0707);
}
if (file_exists($thumb))
$img = "<img src='$thumb' border='0' title='" . $list[$i]['bf_source'] . " Hit: " . $list[$i]['wr_hit'] . "'>";
$img = "<img src='$thumb' border='0' title='" . $list[$i]['bf_source'] . " Hit: " . $list[$i]['wr_hit'] . "'>";
}
echo "<a href='{$list[$i][href]}'>";
echo "<img src='{$img}' border=0' >";
echo "<br><br><a href='{$list[$i][href]}'>$wr_subject</a> <span class='t10'><font class='t_point_color1'>{$list[$i]['comment_cnt']}</font></span>";
?>
echo "<img src='{$img}' border=0' >";
echo "<br><br><a href='{$list[$i][href]}'>$wr_subject</a> <span class='t10'><font class='t_point_color1'>{$list[$i]['comment_cnt']}</font></span>";
?>
</td>
</tr>
</table></td>
</tr>
<? } ?>
<? if (count($list) == 0) { ?><tr><td colspan=4 align=center height=50>게시물이 없습니다.</a></td></tr><? } ?>
</table>
</tr>
</table></td>
</tr>
<? } ?>
<? if (count($list) == 0) { ?><tr><td colspan=4 align=center height=50>게시물이 없습니다.</a></td></tr><? } ?>
</table>
댓글 전체