이미지 등록과 함께 썸네일 파일 생성하기 write_update.skin.php파일 정보
이미지 등록과 함께 썸네일 파일 생성하기 write_update.skin.php파일첨부파일
본문
내용 : 까만도둑님이 올려주신 썸네임 겔러리 스킨 응용
http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=714
-- 적용방법 게시판의 여분필드4 @80@100@15 동일
-- 첫번째 등록된 이미지만 생성
-- 파일 /extend/thum.lib.php, 각 스킨파일의 write_update.skin.php
-- 이미 등록된 이미지는 수정/저장 하시면 자동 생성됩니다.
관련 파일은 아래 내용입니다... 참고하세요..
#extend/thum.lib.php
------여기부터
<?
function smaller( $W, $H ) {
global $max, $thum_W, $thum_H ;
if ( $W > $H ) { //가로형일 경우.
$thum_W = $max ;
$thum_H = ceil( $H * ( $max / $W ) );
}
if ( $W < $H ) { //세로형일 경우.
$thum_H = $max ;
$thum_W = ceil( $W * ( $max / $H ) );
}
if ( $W == $H ) { //정사각형일 경우.
$thum_W = ceil( $max * 0.8 );
$thum_H = ceil( $max * 0.8 );
}
return $thum_W ;
return $thum_H ;
}
function maker( $thum_W, $thum_H ) {
global $thum, $resol, $ori, $ori_info;
//$newImg = ImageCreate($thum_W,$thum_H); // GD라이브러리 2.0 (이하일 경우)
$newImg = ImageCreateTrueColor($thum_W,$thum_H); // GD라이브러리 2.0 전용함수
if($ori_info[2]=="2") $origImg=ImageCreateFromjpeg($ori);
if($ori_info[2]=="3") $origImg=ImageCreateFrompng($ori);
//ImageCopyResized($newImg,$origImg,0,0,0,0,$thum_W,$thum_H,ImageSX($origImg),ImageSY($origImg));
imageCopyResampled($newImg,$origImg,0,0,0,0,$thum_W,$thum_H,ImageSX($origImg),ImageSY($origImg));
Imagejpeg($newImg, $thum, $resol );
chmod($thum,0707);
ImageDestroy($newImg);
ImageDestroy($origImg);
return $thum ;
}
?>
------------------------------------------------------------------------------ 여기까지
#적용스킨의 write_update.skin.php
------------------------------------------------------------------------------- 여기부터
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 자신만의 코드를 넣어주세요.
if($board[bo_4]) {
$smark = substr($board[bo_4],0,1); // 제목의 구분자를 파악한다.
$itemtitle = explode("$smark", $board[bo_4]); // 제목 구분자로 제목을 나눈다.
}
$noIMG = ""; //[필수](URL)
$max = $itemtitle[1] ; //[필수](픽셀) // 썸네일 이미지의 가로세로(긴쪽)의 최대치.
$resol = $itemtitle[2] ; //[필수](퍼센트%) // 생성되는 썸네일의 JPG압축률.
$str = $itemtitle[3] ; //[필수](글자수) // 썸네일 밑의 제목의 글자수.
//$image_width = 80; // 이미지 폭
//$image_height = 60; // 이미지 높이
//수정 부분
$sql2 = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$result2 = sql_query($sql2);
$row = sql_fetch_array($result2);
$image = urlencode($row[bf_file]);
$ori="$g4[path]/data/file/$bo_table/".$image;
//$ori="$g4[path]/data/file/$bo_table/" . $image;
$ext = strtolower(substr(strrchr($ori,"."), 1)); //확장자
//if ( file_exists($ori) ) $ori_info=getimagesize($ori); else $ori_info=""; //파일이 있을 경우, 확장자 지정.
if ( $ext=="gif"||$ext=="jpg"||$ext=="jpeg"||$ext=="png"||$ext=="bmp"||$ext=="tif"||$ext=="tiff") $ori_info=getimagesize($ori); else $ori_info="";
if ( $ori_info[2]=="2" || $ori_info[2]=="3" ) { //============================================================ 원파일이 [ 2JPG, 2JPEG, 3PNG ] 경우.
$thum = $ori.".Thum" ;
if ( file_exists($thum) ) { // Thumbnail [O] 경우
$thum_info = getimagesize ($thum);
$thum_W = $thum_info[0] ;
$thum_H = $thum_info[1] ;
} else { // Thumbnail [X] 경우
if ( smaller( $ori_info[0], $ori_info[1] ) ) {
maker( $thum_W, $thum_H );
}
}
} else if ( $ori_info[2]=="1" || $ori_info[2]=="6" || $ori_info[2]=="7" ) { //=================== 원파일이 [ 1GIF,6BMP,7TIF ] 경우.
if ( smaller( $ori_info[0], $ori_info[1] ) ) {
$thum = $ori ;
}
} else { //========================================================================================= 원파일이 [ 1,2,3,6,7 ] 아닐 경우.
$thum = $noIMG ;
$noIMG_info = getimagesize ($noIMG);
$thum_W = $noIMG_info[0] ;
$thum_H = $noIMG_info[1] ;
}
?>
----------------------------------------------------여기까지
http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=714
-- 적용방법 게시판의 여분필드4 @80@100@15 동일
-- 첫번째 등록된 이미지만 생성
-- 파일 /extend/thum.lib.php, 각 스킨파일의 write_update.skin.php
-- 이미 등록된 이미지는 수정/저장 하시면 자동 생성됩니다.
관련 파일은 아래 내용입니다... 참고하세요..
#extend/thum.lib.php
------여기부터
<?
function smaller( $W, $H ) {
global $max, $thum_W, $thum_H ;
if ( $W > $H ) { //가로형일 경우.
$thum_W = $max ;
$thum_H = ceil( $H * ( $max / $W ) );
}
if ( $W < $H ) { //세로형일 경우.
$thum_H = $max ;
$thum_W = ceil( $W * ( $max / $H ) );
}
if ( $W == $H ) { //정사각형일 경우.
$thum_W = ceil( $max * 0.8 );
$thum_H = ceil( $max * 0.8 );
}
return $thum_W ;
return $thum_H ;
}
function maker( $thum_W, $thum_H ) {
global $thum, $resol, $ori, $ori_info;
//$newImg = ImageCreate($thum_W,$thum_H); // GD라이브러리 2.0 (이하일 경우)
$newImg = ImageCreateTrueColor($thum_W,$thum_H); // GD라이브러리 2.0 전용함수
if($ori_info[2]=="2") $origImg=ImageCreateFromjpeg($ori);
if($ori_info[2]=="3") $origImg=ImageCreateFrompng($ori);
//ImageCopyResized($newImg,$origImg,0,0,0,0,$thum_W,$thum_H,ImageSX($origImg),ImageSY($origImg));
imageCopyResampled($newImg,$origImg,0,0,0,0,$thum_W,$thum_H,ImageSX($origImg),ImageSY($origImg));
Imagejpeg($newImg, $thum, $resol );
chmod($thum,0707);
ImageDestroy($newImg);
ImageDestroy($origImg);
return $thum ;
}
?>
------------------------------------------------------------------------------ 여기까지
#적용스킨의 write_update.skin.php
------------------------------------------------------------------------------- 여기부터
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 자신만의 코드를 넣어주세요.
if($board[bo_4]) {
$smark = substr($board[bo_4],0,1); // 제목의 구분자를 파악한다.
$itemtitle = explode("$smark", $board[bo_4]); // 제목 구분자로 제목을 나눈다.
}
$noIMG = ""; //[필수](URL)
$max = $itemtitle[1] ; //[필수](픽셀) // 썸네일 이미지의 가로세로(긴쪽)의 최대치.
$resol = $itemtitle[2] ; //[필수](퍼센트%) // 생성되는 썸네일의 JPG압축률.
$str = $itemtitle[3] ; //[필수](글자수) // 썸네일 밑의 제목의 글자수.
//$image_width = 80; // 이미지 폭
//$image_height = 60; // 이미지 높이
//수정 부분
$sql2 = " select * from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' ";
$result2 = sql_query($sql2);
$row = sql_fetch_array($result2);
$image = urlencode($row[bf_file]);
$ori="$g4[path]/data/file/$bo_table/".$image;
//$ori="$g4[path]/data/file/$bo_table/" . $image;
$ext = strtolower(substr(strrchr($ori,"."), 1)); //확장자
//if ( file_exists($ori) ) $ori_info=getimagesize($ori); else $ori_info=""; //파일이 있을 경우, 확장자 지정.
if ( $ext=="gif"||$ext=="jpg"||$ext=="jpeg"||$ext=="png"||$ext=="bmp"||$ext=="tif"||$ext=="tiff") $ori_info=getimagesize($ori); else $ori_info="";
if ( $ori_info[2]=="2" || $ori_info[2]=="3" ) { //============================================================ 원파일이 [ 2JPG, 2JPEG, 3PNG ] 경우.
$thum = $ori.".Thum" ;
if ( file_exists($thum) ) { // Thumbnail [O] 경우
$thum_info = getimagesize ($thum);
$thum_W = $thum_info[0] ;
$thum_H = $thum_info[1] ;
} else { // Thumbnail [X] 경우
if ( smaller( $ori_info[0], $ori_info[1] ) ) {
maker( $thum_W, $thum_H );
}
}
} else if ( $ori_info[2]=="1" || $ori_info[2]=="6" || $ori_info[2]=="7" ) { //=================== 원파일이 [ 1GIF,6BMP,7TIF ] 경우.
if ( smaller( $ori_info[0], $ori_info[1] ) ) {
$thum = $ori ;
}
} else { //========================================================================================= 원파일이 [ 1,2,3,6,7 ] 아닐 경우.
$thum = $noIMG ;
$noIMG_info = getimagesize ($noIMG);
$thum_W = $noIMG_info[0] ;
$thum_H = $noIMG_info[1] ;
}
?>
----------------------------------------------------여기까지
추천
0
0
댓글 8개
도둑님은 늘 바쁘시겠네요 ㅋㅋ

짱이예요^^

아 수고 하셨습니다. ^^
이렇게 했더니 gif 파일은 썸네일이 안만들어지는데요?
그리구 글수정으로 이미지 변경해도 기존 썸네일 삭제도 안되구 ㅠㅠ
그리구 글수정으로 이미지 변경해도 기존 썸네일 삭제도 안되구 ㅠㅠ
굿 팁 ^^

저장과 동시 썸네일 생성
좋은 정보 감사합니다~~^^

정말 감사합니다.^^