이미지 등록과 함께 썸네일 파일 생성하기 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] ;
}
?>
----------------------------------------------------여기까지
댓글 8개
파티캐스트
20년 전
도둑님은 늘 바쁘시겠네요 ㅋㅋ
20년 전
짱이예요^^
20년 전
아 수고 하셨습니다. ^^
19년 전
이렇게 했더니 gif 파일은 썸네일이 안만들어지는데요?
그리구 글수정으로 이미지 변경해도 기존 썸네일 삭제도 안되구 ㅠㅠ
그리구 글수정으로 이미지 변경해도 기존 썸네일 삭제도 안되구 ㅠㅠ
18년 전
굿 팁 ^^
14년 전
저장과 동시 썸네일 생성
12년 전
좋은 정보 감사합니다~~^^
12년 전
정말 감사합니다.^^
게시판 목록
그누4 팁자료실
그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.
나누면 즐거움이 커집니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3189 |
|
12년 전 | 6699 | |
| 3188 | 12년 전 | 4369 | ||
| 3187 | 12년 전 | 5645 | ||
| 3186 | 12년 전 | 5234 | ||
| 3185 | 12년 전 | 4849 | ||
| 3184 | 12년 전 | 4812 | ||
| 3183 | 12년 전 | 3867 | ||
| 3182 | 12년 전 | 6997 | ||
| 3181 |
skpal
|
12년 전 | 6373 | |
| 3180 | 12년 전 | 5741 | ||
| 3179 | 12년 전 | 5183 | ||
| 3178 | 12년 전 | 4029 | ||
| 3177 |
soul5932
|
12년 전 | 6474 | |
| 3176 |
다케미카코
|
12년 전 | 3736 | |
| 3175 |
soul5932
|
12년 전 | 12915 | |
| 3174 | 12년 전 | 11140 | ||
| 3173 | 12년 전 | 5300 | ||
| 3172 | 12년 전 | 6047 | ||
| 3171 | 12년 전 | 5501 | ||
| 3170 | 12년 전 | 5483 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기