2026, 새로운 도약을 시작합니다.

gif 움짤 첫번째 이미지로 썸네일 만들기

gif애니메이션 썸네일 방법이 몇가지 있긴한데요. 그냥 정적 이미지로 썸네일 만드는 방법도 괜찮은 것 같아서 올려봅니다.

/lib/thumbnail.lib.php
490라인 gif관련해서 아래 소스와 비교

[code=php]
// gif관련 주석처리
// Animated GIF는 썸네일 생성하지 않음
// if($size[2] == 1) {
// if(is_animated_gif($source_file))
// return basename($source_file);
// }

$ext = array(1 => 'gif', 2 => 'jpg', 3 => 'png');

$thumb_filename = preg_replace("/\.[^\.]+$/i", "", $filename); // 확장자제거
$thumb_file = "$target_path/thumb-{$thumb_filename}_{$thumb_width}x{$thumb_height}.".$ext[$size[2]];

$thumb_time = @filemtime($thumb_file);
$source_time = @filemtime($source_file);

if (is_file($thumb_file)) {
if ($is_create == false && $source_time < $thumb_time) {
return basename($thumb_file);
}
}

// 원본파일의 GD 이미지 생성
$src = null;
$degree = 0;

//gif 파일인 경우
if ($size[2] == 1) {
// gif가 애니메이션 인경우
if(is_animated_gif($source_file)){
$tmpgifarr = explode("\x00\x21\xF9\x04",file_get_contents($source_file));
if (strlen($tmpgifarr[0]) < strlen($tmpgifarr[1])/2){
$tmpgifhead = substr($tmpgifarr[0],0,10);
$tmpgif = $tmpgifhead.$tmpgifarr[1];
}else{
$tmpgif = $tmpgifarr[0];
}
$fhgif = @fopen($source_file."_tmp", 'w');
fwrite($fhgif,$tmpgif);
fclose($fhgif);

$src = @imagecreatefromgif($source_file."_tmp");
unlink($source_file."_tmp");
$src_transparency = @imagecolortransparent($src);
}else{
$src = @imagecreatefromgif($source_file);
$src_transparency = @imagecolortransparent($src);
}
} else if ($size[2] == 2) {
$src = @imagecreatefromjpeg($source_file);
[/code]


/bbs/write_update.php
920 라인쯤 아래 코드를 주석처리
[code=php]
//if($is_animated)
//continue;
[/code]


빌더 사용의 경우 아래의 리눅스 명령어로 관련 함수 사용위치를 점검해 보시면 될 것 같습니다.

find . -name "*.php" | xargs grep "is_animated_gif"
|

댓글 3개

오!! 감사합니다..
이렇게 했는데 안되네요 도움 부탁드립니다 ㅜㅜ

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

그누보드5 팁자료실

번호 제목 글쓴이 날짜 조회
공지 3년 전 조회 4,598
2741 3일 전 조회 110
2740 4일 전 조회 102
2739 1주 전 조회 208
2738 1주 전 조회 217
2737 1주 전 조회 181
2736 1주 전 조회 278
2735 3주 전 조회 281
2734 3주 전 조회 263
2733 1개월 전 조회 265
2732 1개월 전 조회 301
2731 1개월 전 조회 266
2730 1개월 전 조회 224
2729 1개월 전 조회 353
2728 1개월 전 조회 245
2727 1개월 전 조회 422
2726 1개월 전 조회 256
2725 1개월 전 조회 330
2724 1개월 전 조회 358
2723 1개월 전 조회 267
2722 1개월 전 조회 299
2721 1개월 전 조회 211
2720 2개월 전 조회 304
2719 2개월 전 조회 307
2718 2개월 전 조회 201
2717 2개월 전 조회 336
2716 2개월 전 조회 202
2715 2개월 전 조회 311
2714 2개월 전 조회 273
2713 2개월 전 조회 376
2712 2개월 전 조회 289
🐛 버그신고