이미지 수정방법 정보
이미지 수정방법
본문
http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=102186
이것은 임경희님이 불량감자님과 탑스쿨님의 오토무빙갤러리를 수정한
오토무빙 베너입니다.
이 베너를 사용해보니까요 두가지 문제가 발생했습니다.
1. 이미지를 좀 더 크게 하니 해상도가 너무 떨어져서 흐릿해 집니다.
해상도가 원본소스처럼 나오게 하려면 어떻게 해야 하나요?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$img_width = 450;
$img_height = 150;
$img_quality = 90;
if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");
$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb_ch01';
$ym = date("ym", $g4[server_time]);
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
//코멘트와 리플글은 제외
$sql = " select * from $tmp_write_table
where wr_comment = '' and wr_reply = ''
order by wr_id DESC LIMIT 0, 1 ";
$result = sql_query($sql);
$last_con = sql_fetch_array($result);
?>
<SCRIPT type=text/javascript>
<!--
old_debate_T='1';
function ComeonT(objid_T){
document.getElementById("debate_T"+old_debate_T).style.display="none";
document.getElementById("debate_T"+old_debate_T+"#1").style.display="";
document.getElementById("debate_T"+objid_T+"#1").style.display="none";
document.getElementById("debate_T"+objid_T).style.display="";
document.getElementById("debate_content_T"+old_debate_T).style.display="none";
document.getElementById("debate_content_T"+objid_T).style.display="";
old_debate_T=objid_T;
}
var objid_T = 1;
var interval_best;
function best_changeT()
{
if( objid_T == 10 ) // 오버랩되는 갯수
objid_T = 1;
else
objid_T++;
ComeonT(objid_T);
}
function setInterval_best()
{
interval_best = setInterval("best_changeT()",5000);//속도조절
}
function clearInterval_best()
{
clearInterval(interval_best);
}
setInterval_best();
//-->
</SCRIPT>
<style type="text/css">
#ifocus { margin:0px; border:0px;position:relative; }
/* 만약 이미지에 테두리를 넣고 싶다면, 아래의 border:0; 을 border:1px solid #666; 로 수정하면 됩니다.*/
#ifocus img { display:inline; position:relative;border:0px; overflow:hidden; }
#ifocus .imglist { position:relative; }
#onetapbutton {position:absolute; top:135px;right:10px; z-index:30;}
</style>
<!--
이 스킨은 불량감자님의 갤러리 최신글 02(오토탭무빙)을 TopSchooL님께서 보완하신 소스를 배너형태로 사용하기 위해 수정한 소스입니다.
원본 : http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=90060
수정본 : http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=90864
-->
<div style="position:relative">
<? for ($i=0; $i<count($list); $i++) {
$j = $i + 1;
if ($j == "1") {
echo "<DIV>";
echo "<DIV id=debate_content_T$j onmouseover=clearInterval_best() onmouseout=setInterval_best()>"; }
else { echo "<DIV id=debate_content_T$j onmouseover=clearInterval_best() onmouseout=setInterval_best() style='DISPLAY: none;'>\n"; }
?>
<?
//썸네일 생성
$thumfile = "";
$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 = $img_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
} else { //게디터에서 삽입한 이미지 뽑자ㅠㅠ
$edit_img = $list[$i]['wr_content'];
if (eregi("data/cheditor4/{$ym}/[^<>]*\.(gif|jpg|png|bmp)", $edit_img, $tmp)) { // data/geditor------
$file = './' . $tmp[0]; // 파일명
$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_width / $size[0];
$height = (int)($size[1] * $rate);
// 계산된 썸네일 이미지의 높이가 설정된 이미지의 높이보다 작다면
if ($height < $img_height)
// 계산된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $height);
else
// 설정된 이미지 높이로 복사본 이미지 생성
$dst = imagecreatetruecolor($img_width, $img_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $img_width, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $img_quality);
chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
}
}
}
if (file_exists($thumb))
$thumfile = "<img src='$thumb' width='{$img_width}' height='{$img_height}'></a>";
else
//이미지가 없으면
$thumfile="<img src='$latest_skin_path/img/no_image.gif' width='{$img_width}' height='{$img_height}'></a>";
//이미지가 아니네
if(preg_match("/\.(swf|wma|asf)$/i","$file") && file_exists($file))
{ $thumfile = "<script>doc_write(flash_movie('$file', 'flash$i', '$img_width', '$img_height', 'transparent'));</script>"; }
?>
<div id="ifocus">
<div class="imglist">
<? if ($list[$i][wr_link1]) {
echo "<a href='{$list[$i][wr_link1]}' target='_blank'>{$thumfile}</a>"; //새창으로 링크 연결
//echo "<a href='{$list[$i][wr_link1]}' target='_self'>{$thumfile}</a>"; //현재창으로 링크 연결
} else {
echo "<a href='{$list[$i][href]}'>{$thumfile}</a>";
}
?>
</div>
</div>
<?
echo "</DIV>";
}
?>
<div id="onetapbutton">
<? for ($i=0; $i<count($list); $i++) {
$k = $i + 1;
?>
<a href="<?=$list[$i][href]?>" onmouseover="javascript:ComeonT('<?=$k?>')"><img src="<?=$latest_skin_path?>/img/<?=$k?>_on.gif" width="12" height="12" border="0" id="debate_T<?=$k?>" onmouseover="clearInterval_best()" onmouseout="setInterval_best()" <? if($k == "1") { echo ""; } else { echo "style='DISPLAY: none;' "; } ?>><img src="<?=$latest_skin_path?>/img/<?=$k?>.gif" width="12" height="12" border="0" id="debate_T<?=$k?>#1" <? if($k == "1") { echo "style='DISPLAY: none;'"; } else { echo ""; } ?>></a>
<?}?>
<a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src="<?=$latest_skin_path?>/img/icon_admin.gif" width="12" height="12" border="0" alt="목록으로"></a>
</div>
</div>
댓글 전체
이 말씀은 작게 만들어진 썸네일을 img태그에서 width, height를 크게 주었다는 얘긴가요?
썸네일을 만들때 원하는 사이즈로 만들면 흐릿해지지 않습니다
$img_width = 450; $img_height = 150; 이부분을 원하는 크기로 하면 될텐데요?
2. 이 부분 링크 문제 인데요
맨 위쪽 for문 바로 위에서 링크주소를 변경해버리면 됩니다
$list[0][href]="$g4[path]/baner/baner1.html";
$list[1][href]="$g4[path]/baner/test1.html";
이런식으로 링크시킬 주소를 모두 써주면 되죠
2번
<!--
이 스킨은 불량감자님의 갤러리 최신글 02(오토탭무빙)을 TopSchooL님께서 보완하신 소스를 배너형태로 사용하기 위해 수정한 소스입니다.
원본 : http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=90060
수정본 : http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=90864
-->
<div style="position:relative">
<?
<==================================== 삽입할 위치
for ($i=0; $i<count($list); $i++) {
$j = $i + 1;
if ($j == "1") {
echo "<DIV>";
echo "<DIV id=debate_content_T$j onmouseover=clearInterval_best() onmouseout=setInterval_best()>"; }
else { echo "<DIV id=debate_content_T$j onmouseover=clearInterval_best() onmouseout=setInterval_best() style='DISPLAY: none;'>\n"; }
?>
썸네일 만드는 부분은 차라리 리스트에 보여지는 이미지 부분에 사용하세요
그리고 배너 이미지를 저장해서 사이즈를 보세요
450 x 109 입니다
이걸 619x150으로 보여주니 찌그러질 밖에요
$img_width = 619; $img_height = 150 으로 변경해도 이미 만들어진 썸네일 이미지가 있으면
다시 만들지 않습니다(그렇게 하지않으면 메인 페이지 볼때마다 섬네일을 만들게 됩니다)
thumb_ch01 폴더에서 예전에 만들어진 이미지를 모두 지우면 새로운 사이즈로 다시 만듭니다
그렇지만 만들 필요가 없습니다(원본과 배너가 크기가 같으므로)
위 소스에서 썸네일 만드는 부분은 삭제해버리고 원본 이미지를 링크하는 것이 엄청 효율적입니다
썸네일 생성 부분에서 아래 부분만 남기고 모두 삭제 후
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
echo "<a href='{$list[$i][href]}'>{$thumfile}</a>"; 이부분을
echo "<a href='{$list[$i][href]}'>{$file}</a>"; 로 변경 하면 됩니다
<? if ($list[$i][wr_link1]) { 아래쪽 모두 위와 같이 썸네일 자리에 $file 로 수정하세요

썸네일 코드는 같은 배너라면 필요가 없어서 모두 삭제한 후
참고로 위의 답변에서
$file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
를
$file = "<img src=".$list[$i][file][0][path] ."/". $list[$i][file][0][file]. ">";
로 해야 합니다^^