키

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

· 2017-05-13 (토) 19:35:57 · 10340 · 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개

감사합니다!
오!! 감사합니다..
이렇게 했는데 안되네요 도움 부탁드립니다 ㅜㅜ
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

2,788건
+
제목 글쓴이 날짜 조회
17-05-22 조회 7,129
17-05-20 조회 5,968
17-05-19 조회 7,870
17-05-19 조회 7,724
17-05-18 조회 5,928
17-05-18 조회 8,849
17-05-18 조회 6,813
17-05-18 조회 1.1만
17-05-18 조회 1만
17-05-18 조회 7,959
17-05-17 조회 5,519
17-05-17 조회 6,633
17-05-17 조회 5,894
17-05-17 조회 7,719
17-05-16 조회 7,012
17-05-16 조회 7,032
17-05-16 조회 7,863
17-05-13 조회 1만
17-05-12 조회 8,984
17-05-08 조회 1.7만
17-05-08 조회 1.2만
17-05-07 조회 1.3만
17-05-07 조회 6,586
17-05-04 조회 7,117
17-05-03 조회 7,520
17-05-02 조회 9,092
17-05-01 조회 1.1만
17-04-27 조회 7,436
17-04-26 조회 1.3만
17-04-24 조회 9,137