썸네일을 이용한 겔러리 최신글 이미지 퀄리티 질문입니다. 정보
썸네일을 이용한 겔러리 최신글 이미지 퀄리티 질문입니다.본문
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 썸네일 생성 갤러리 전용 최신글
// 이미지 가로 및 세로 정렬 기능
// 최신글에 불러들일 썸네일의 사이즈를 변경하려면 (처음 설치시는 해당없음)
// 우선 썸네일폭을 아래에서 지정하고
// data/file/테이블명/latest_thumb/파일 전체삭제 후 실행합니다.
$cols = 6; // 이미지 가로갯수 = 이미지 세로 갯수는 메인(index.php)에서 지정(총 이미지 수)
$image_h = 10; // 이미지 상하 간격
$thum_width = "90"; //목록에서 보여질 썸네일 폭 (픽셀)
$image_quality = "60"; //목록에서 보여질 이미지의 압축률 (100 이하)
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/latest_thumb'; // 썸네일 생성 폴더명
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height=23>
<tr>
<td> <img src="<?=$latest_skin_path?>/img/board_head.gif" align=absmiddle border=0> <a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><font style='font-family:돋움; font-size:9pt; color:#696969;'><strong><?=$board[bo_subject]?></strong></font></a> </td>
<td width="60" align="right"><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src="<?=$latest_skin_path?>/img/board_more.gif" border="0"></a></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height=3>
<tr>
<td width="9" height="3"><img src="<?=$latest_skin_path?>/img/board_title_line1.gif" width=9 height=3 border=0></td>
<td height=3 width="30%" background="<?=$latest_skin_path?>/img/board_title_line2.gif"></td>
<td width="90%" background="<?=$latest_skin_path?>/img/board_title_line3.gif"></td>
</tr>
</table>
</td>
</tr>
<tr><td height="15" ></td></tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<? for ($i=0; $i<count($list); $i++) {
if ($i>0 && $i%$cols==0) { echo "</tr><tr><td colspan='$cols' height='$image_h'></td></tr><tr>"; }
?>
<td align="center" valign='top' style='padding-left:3px;'>
<?
$img = "이미지 없음";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
if (!file_exists($thumb))
{
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
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
break;
$rate = $thum_width / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($thum_width, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thum_width, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $image_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
if (file_exists($thumb))
$img = "<img src='$thumb' alt='{$list[$i][subject]}' border='0' style='border:1 solid #C6C6C6;'>";
// $img = "<img src='$thumb' alt='{$list[$i][subject]}' width='90' height='60' border='0' style='border:1 solid #C6C6C6;'>"; // 썸네일 가로 세로 고정시 사용
echo $list[$i][icon_reply] . " ";
echo "<table cellpadding=0 cellspacing=0 border=0><tr>";
echo "<td><a href=\"{$list[$i][href]}\">$img</a></td>";
echo "<td width=2 bgcolor=#DDDDDD style='border-top:3px solid #FFFFFF'><img width=2 height=1></td></tr>";
echo "<tr><td colspan=2 height=2 bgcolor=#DDDDDD style='border-left:3px solid #FFFFFF'><img width=1 height=2></td></tr>";
echo "<tr><td colspan=2 height=2><img width=1 height=2></td></tr></table>";
echo "<span style='cursor:default;'><font color='#BCCFCD'></font> <font style=color:#393939;'>{$list[$i][subject]}</font> <font color='#BCCFCD'></font></span> ";
?>
</td>
<? } ?>
<?
$cnt = ($i%$cols);
for ($k=$cnt; $k<$cols && $cnt; $k++) {
echo "<td></td>";
}
?>
<? if (count($list) == 0) { echo "<td height=80 align=center>게시물이 없습니다.</td>"; } ?>
</tr>
</table></td>
</tr>
<tr><td height="5"></td></tr>
</table>
일반스킨 자료실에 있던 것 받아서 수정해서 잘 쓰고 있습니다. ^^ 제작자분께 감사드립니다.
위에 소스를 보면 분명, 이미지 퀄리티를 60으로 설정했는데... 이미지가 10KB 이상이 나오길래
숫자를 바꿔가면서 이미지를 올려봤습니다... 용량은 여전합니다;;;
원인이 무엇인지 알고 싶습니다... 답변 부탁드립니다. (__)
FreeBSD 6.0 Release / Apache 1.3.33 / PHP 4.4.0 / GD bundled (2.0.28 compatible) 환경입니다.
음... 최신글의 스킨으로써가 아니라 보드의 겔러리형 스킨은 용량의 변화가 있는걸 보니 잘 동작하고 있는데 말입니다;;
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 썸네일 생성 갤러리 전용 최신글
// 이미지 가로 및 세로 정렬 기능
// 최신글에 불러들일 썸네일의 사이즈를 변경하려면 (처음 설치시는 해당없음)
// 우선 썸네일폭을 아래에서 지정하고
// data/file/테이블명/latest_thumb/파일 전체삭제 후 실행합니다.
$cols = 6; // 이미지 가로갯수 = 이미지 세로 갯수는 메인(index.php)에서 지정(총 이미지 수)
$image_h = 10; // 이미지 상하 간격
$thum_width = "90"; //목록에서 보여질 썸네일 폭 (픽셀)
$image_quality = "60"; //목록에서 보여질 이미지의 압축률 (100 이하)
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/latest_thumb'; // 썸네일 생성 폴더명
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height=23>
<tr>
<td> <img src="<?=$latest_skin_path?>/img/board_head.gif" align=absmiddle border=0> <a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><font style='font-family:돋움; font-size:9pt; color:#696969;'><strong><?=$board[bo_subject]?></strong></font></a> </td>
<td width="60" align="right"><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src="<?=$latest_skin_path?>/img/board_more.gif" border="0"></a></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height=3>
<tr>
<td width="9" height="3"><img src="<?=$latest_skin_path?>/img/board_title_line1.gif" width=9 height=3 border=0></td>
<td height=3 width="30%" background="<?=$latest_skin_path?>/img/board_title_line2.gif"></td>
<td width="90%" background="<?=$latest_skin_path?>/img/board_title_line3.gif"></td>
</tr>
</table>
</td>
</tr>
<tr><td height="15" ></td></tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<? for ($i=0; $i<count($list); $i++) {
if ($i>0 && $i%$cols==0) { echo "</tr><tr><td colspan='$cols' height='$image_h'></td></tr><tr>"; }
?>
<td align="center" valign='top' style='padding-left:3px;'>
<?
$img = "이미지 없음";
$thumb = $thumb_path.'/'.$list[$i][wr_id];
if (!file_exists($thumb))
{
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
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
break;
$rate = $thum_width / $size[0];
$height = (int)($size[1] * $rate);
$dst = imagecreatetruecolor($thum_width, $height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thum_width, $height, $size[0], $size[1]);
imagepng($dst, $thumb_path.'/'.$list[$i][wr_id], $image_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
if (file_exists($thumb))
$img = "<img src='$thumb' alt='{$list[$i][subject]}' border='0' style='border:1 solid #C6C6C6;'>";
// $img = "<img src='$thumb' alt='{$list[$i][subject]}' width='90' height='60' border='0' style='border:1 solid #C6C6C6;'>"; // 썸네일 가로 세로 고정시 사용
echo $list[$i][icon_reply] . " ";
echo "<table cellpadding=0 cellspacing=0 border=0><tr>";
echo "<td><a href=\"{$list[$i][href]}\">$img</a></td>";
echo "<td width=2 bgcolor=#DDDDDD style='border-top:3px solid #FFFFFF'><img width=2 height=1></td></tr>";
echo "<tr><td colspan=2 height=2 bgcolor=#DDDDDD style='border-left:3px solid #FFFFFF'><img width=1 height=2></td></tr>";
echo "<tr><td colspan=2 height=2><img width=1 height=2></td></tr></table>";
echo "<span style='cursor:default;'><font color='#BCCFCD'></font> <font style=color:#393939;'>{$list[$i][subject]}</font> <font color='#BCCFCD'></font></span> ";
?>
</td>
<? } ?>
<?
$cnt = ($i%$cols);
for ($k=$cnt; $k<$cols && $cnt; $k++) {
echo "<td></td>";
}
?>
<? if (count($list) == 0) { echo "<td height=80 align=center>게시물이 없습니다.</td>"; } ?>
</tr>
</table></td>
</tr>
<tr><td height="5"></td></tr>
</table>
일반스킨 자료실에 있던 것 받아서 수정해서 잘 쓰고 있습니다. ^^ 제작자분께 감사드립니다.
위에 소스를 보면 분명, 이미지 퀄리티를 60으로 설정했는데... 이미지가 10KB 이상이 나오길래
숫자를 바꿔가면서 이미지를 올려봤습니다... 용량은 여전합니다;;;
원인이 무엇인지 알고 싶습니다... 답변 부탁드립니다. (__)
FreeBSD 6.0 Release / Apache 1.3.33 / PHP 4.4.0 / GD bundled (2.0.28 compatible) 환경입니다.
음... 최신글의 스킨으로써가 아니라 보드의 겔러리형 스킨은 용량의 변화가 있는걸 보니 잘 동작하고 있는데 말입니다;;
댓글 전체
제가 올린거네요.
썸네일 이미지 폭이 90정도 작은 것은 표가 잘 안나서...
썸네일 사이즈가 크면 확실하게 용량에 차이가 있습니다.
퀄리티 100으로하면 품질은 좋은 반면 용량도 커집니다.
환경은 통과...
용량이 보통 10KB 전후로 다 나오네요.
제것 확인해 보니까...
썸네일 이미지 폭이 90정도 작은 것은 표가 잘 안나서...
썸네일 사이즈가 크면 확실하게 용량에 차이가 있습니다.
퀄리티 100으로하면 품질은 좋은 반면 용량도 커집니다.
환경은 통과...
용량이 보통 10KB 전후로 다 나오네요.
제것 확인해 보니까...