테스트 사이트 - 개발 중인 베타 버전입니다

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

· 8년 전 · 8086 · 3
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개

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

게시글 목록

번호 제목
24149
24140
24133
24125
24119
24109
24105
24101
24093
24089
24077
24074
24071
24070
24067
24056
24050
24046
24043
24040
24037
24036
24035
24034
24021
24017
24005
24002
23990
23980