애니메이션 GIF 갤러리형 게시판 목록에서 정지영상으로 썸네일 추출 > 그누보드5 팁자료실

그누보드5 팁자료실

애니메이션 GIF 갤러리형 게시판 목록에서 정지영상으로 썸네일 추출 정보

애니메이션 GIF 갤러리형 게시판 목록에서 정지영상으로 썸네일 추출

첨부파일

agifstamp.gif (194byte) 57회 다운로드 2018-05-01 12:17:46

본문

그누보드 5.2.9 용 입니다.

 

기본 스킨 갤러리형 게시판 목록에서 트래픽 절감을 위해 정지영상으로 처리합니다. (게시물 읽기에는 영향 없음)

 

lib/thumbnail.lib.php

 

수정할 부분 1

 

아래 내용 찾아서


    // Animated GIF는 썸네일 생성하지 않음
    if($size[2] == 1) {
        if(is_animated_gif($source_file))
            return basename($source_file);
    }

 

아래 코드로 수정


    // Animated GIF 여부 확인
    $is_anim_gif = 0;
    if($size[2] == 1) {
        $is_anim_gif = is_animated_gif($source_file);
    }

 

수정할 부분 2

 

아래 코드가 있는 부분 찾아서...


    // sharpen 적용
    if($is_sharpen && $is_large) {
        $val = explode('/', $um_value);
        UnsharpMask($dst, $val[0], $val[1], $val[2]);
    }

 

그 아래에 다음 코드 추가

주의 : 움직이는 GIF 구분을 위해 $stamp_data_im 경로에 적당한 워터마크용 파일을 넣으세요. 이 코드 그대로 적용하면 에러 납니다.


    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);
    }

 

코드 적용하고 갤러리 목록에서 새로고침하면 자동으로 썸네일이 생성 됩니다.

 

워터마크용 아이콘 첨부 파일에 넣어 두었으니 따로 만들기 귀찮으면 첨부파일 가져가서 그냥 사용하세요.

추천
4

댓글 10개

적용했는데 아무런 변화가 없네요.
[수정할 부분 2] 에서 내용아래에 추가만 하면되는것인지 아니면 소스에서 아래부분을 삭제하고 추가해야하는것인지  초보자를 위해 자세한 설명 부탁드려요
imagecreatefromgif(<움직이는 GIF 워터마크용 파일.gif>) <--이부분도 이미지 다운받아서
 imagecreatefromgif('../img/agifstamp.gif') 서버에 올려놓고 이렇게 했습니다. 여기서 오류가 발생한건지..
// Animated GIF는 썸네일 생성하지 않음 <- 이 주석 아래 코드를 지우고 수정해야 정상 작동합니다.
두번째 수정할 부분은 위치 알려준 부분 바로 아래에 gif경로 원하는곳으로 수정하고 나머지는 그대로 추가만 하면됩니다.

php 로그에서 오류가 없다면 수정1 부분에서 기존코드 때문에 그냥 리턴하고 빠져나가서 변화가 없는걸로 추정되네요.
빌더나 자체 썸네일 함수를 쓰는 커스텀 스킨에서는 테스트 되지 않아서 순정 버전이 아닌 경우 동작을 보증하지 못해요.
아미나빌더 1.7.26 / 그누보드 5.2.9.8.4 버전  에 사용중입니다.

수정부분 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.4 버전대를 사용하고 있어서 7.x 환경은 아직 테스트를 못해봤어요
조만간 웹서버랑 php 버전업 할예정이라 곧 테스트해보고 다시 답변 드릴께요
전체 2,411 |RSS
그누보드5 팁자료실 내용 검색

회원로그인

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