gif 움짤 첫번째 이미지로 썸네일 만들기 > 그누보드5 팁자료실

그누보드5 팁자료실

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

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"
추천
2

댓글 3개

전체 2,426 |RSS
그누보드5 팁자료실 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT