애니메이션 GIF 갤러리형 게시판 목록에서 정지영상으로 썸네일 추출
그누보드 5.2.9 용 입니다.
기본 스킨 갤러리형 게시판 목록에서 트래픽 절감을 위해 정지영상으로 처리합니다. (게시물 읽기에는 영향 없음)
lib/thumbnail.lib.php
수정할 부분 1
아래 내용 찾아서
[code]
// Animated GIF는 썸네일 생성하지 않음
if($size[2] == 1) {
if(is_animated_gif($source_file))
return basename($source_file);
}
[/code]
아래 코드로 수정
[code]
// Animated GIF 여부 확인
$is_anim_gif = 0;
if($size[2] == 1) {
$is_anim_gif = is_animated_gif($source_file);
}
[/code]
수정할 부분 2
아래 코드가 있는 부분 찾아서...
[code]
// sharpen 적용
if($is_sharpen && $is_large) {
$val = explode('/', $um_value);
UnsharpMask($dst, $val[0], $val[1], $val[2]);
}
[/code]
그 아래에 다음 코드 추가
주의 : 움직이는 GIF 구분을 위해 $stamp_data_im 경로에 적당한 워터마크용 파일을 넣으세요. 이 코드 그대로 적용하면 에러 납니다.
[code]
if($is_anim_gif != 0) {
// http://php.net/manual/en/image.examples-watermark.php 인용
// Load the stamp and the photo to apply the watermark to
$stamp_data_im = imagecreatefromgif('<움직이는 GIF 워터마크용 파일.gif>');
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp_data_im);
$sy = imagesy($stamp_data_im);
// Copy the stamp image onto our photo using the margin offsets and the photo
// width to calculate positioning of the stamp.
imagecopy($dst, $stamp_data_im, imagesx($dst) - $sx - $marge_right, imagesy($dst) - $sy - $marge_bottom, 0, 0, imagesx($stamp_data_im), imagesy($stamp_data_im));
// Output and free memory
imagedestroy($stamp_data_im);
}
[/code]
코드 적용하고 갤러리 목록에서 새로고침하면 자동으로 썸네일이 생성 됩니다.
워터마크용 아이콘 첨부 파일에 넣어 두었으니 따로 만들기 귀찮으면 첨부파일 가져가서 그냥 사용하세요.
댓글 10개
[수정할 부분 2] 에서 내용아래에 추가만 하면되는것인지 아니면 소스에서 아래부분을 삭제하고 추가해야하는것인지 초보자를 위해 자세한 설명 부탁드려요
imagecreatefromgif('../img/agifstamp.gif') 서버에 올려놓고 이렇게 했습니다. 여기서 오류가 발생한건지..
두번째 수정할 부분은 위치 알려준 부분 바로 아래에 gif경로 원하는곳으로 수정하고 나머지는 그대로 추가만 하면됩니다.
php 로그에서 오류가 없다면 수정1 부분에서 기존코드 때문에 그냥 리턴하고 빠져나가서 변화가 없는걸로 추정되네요.
수정부분 1
// 디렉토리가 존재하지 않거나 쓰기 권한이 없으면 썸네일 생성하지 않음
if(!(is_dir($target_path) && is_writable($target_path)))
return '';
// Animated GIF 여부 확인
$is_anim_gif = 0;
if($size[2] == 1) {
$is_anim_gif = is_animated_gif($source_file);
}
$ext = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
수정부분 2
// sharpen 적용
if($is_sharpen && $is_large) {
$val = explode('/', $um_value);
UnsharpMask($dst, $val[0], $val[1], $val[2]);
}
if($is_anim_gif != 0) {
// http://php.net/manual/en/image.examples-watermark.php 인용
// Load the stamp and the photo to apply the watermark to
$stamp_data_im = imagecreatefromgif('./img/agifstamp.gif');
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp_data_im);
$sy = imagesy($stamp_data_im);
// Copy the stamp image onto our photo using the margin offsets and the photo
// width to calculate positioning of the stamp.
imagecopy($dst, $stamp_data_im, imagesx($dst) - $sx - $marge_right, imagesy($dst) - $sy - $marge_bottom, 0, 0, imagesx($stamp_data_im), imagesy($stamp_data_im));
// Output and free memory
imagedestroy($stamp_data_im);
}
if($size[2] == 1) {
imagegif($dst, $thumb_file);
} else if($size[2] == 3) {
if(!defined('G5_THUMB_PNG_COMPRESS'))
이렇게 했는데 그대로 움직이네요 ㅠㅠ
혹시나 비교해보시고 이것도 문제 있으면 알려주세요.
https://drive.google.com/open?id=1OPhoQBTTPbGqIb54iScRn1ULpolhca9n
그누보드로 해봐도 똑같네요. 혹시 php 버젼문제일수도 있을까요?
php7.0 버젼 사용중입니다.
아 그리고 친절한 답변 감사합니다.
조만간 웹서버랑 php 버전업 할예정이라 곧 테스트해보고 다시 답변 드릴께요
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4401 | ||
| 2694 | 2개월 전 | 188 | ||
| 2693 | 2개월 전 | 148 | ||
| 2692 | 2개월 전 | 158 | ||
| 2691 | 2개월 전 | 174 | ||
| 2690 | 2개월 전 | 326 | ||
| 2689 | 2개월 전 | 233 | ||
| 2688 |
|
2개월 전 | 440 | |
| 2687 | 2개월 전 | 291 | ||
| 2686 |
선택과집중
|
2개월 전 | 329 | |
| 2685 | 2개월 전 | 290 | ||
| 2684 | 2개월 전 | 346 | ||
| 2683 | 2개월 전 | 481 | ||
| 2682 | 2개월 전 | 276 | ||
| 2681 | 2개월 전 | 301 | ||
| 2680 |
선택과집중
|
2개월 전 | 278 | |
| 2679 | 2개월 전 | 330 | ||
| 2678 |
|
2개월 전 | 429 | |
| 2677 |
|
3개월 전 | 502 | |
| 2676 | 3개월 전 | 326 | ||
| 2675 | 3개월 전 | 304 | ||
| 2674 |
선택과집중
|
3개월 전 | 480 | |
| 2673 |
|
3개월 전 | 322 | |
| 2672 | 3개월 전 | 335 | ||
| 2671 | 3개월 전 | 284 | ||
| 2670 | 3개월 전 | 259 | ||
| 2669 | 3개월 전 | 373 | ||
| 2668 | 3개월 전 | 289 | ||
| 2667 |
선택과집중
|
3개월 전 | 483 | |
| 2666 |
선택과집중
|
3개월 전 | 470 | |
| 2665 |
선택과집중
|
3개월 전 | 404 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기