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

썹네일 이미지 크롭방법 알려주세요ㅠㅠ 채택완료

최선비 7년 전 조회 4,126

//g5/theme/임의의테마명/skin/latest/over_gallery/thumb.lib.php 파일을 수정중에 있습니다.

아무리 crop을 1이나 2 또는 true로 변경해도 가로로 긴 이미지가 정사각형으로 크롭되지가 않고 원형 그대로 축소되는 상황입니다.

양옆을 잘라내서 정사각을 만들고 싶은데 왜 안됄까요ㅠㅠ

방법 좀 알려주세요

 

내용은 이러합니다.

 

 

    $size = getimagesize($imgSource);

    if ($size[2] == 1)         $source = imagecreatefromgif($imgSource);     else if ($size[2] == 2)         $source = imagecreatefromjpeg($imgSource);     else if ($size[2] == 3)         $source = imagecreatefrompng($imgSource);     else         continue;

    $rate = $imgWidth / $size[0];     $height = (int)($size[1] * $rate);

    if ($height < $imgHeight) {

        $target = @imagecreatetruecolor($imgWidth, $height);

    } else {

        $target = @imagecreatetruecolor($imgWidth, $imgHeight);

    }

    @imagecopyresampled($target, $source, 0, 0, 0, 0, $imgWidth, $height, $size[0], $size[1]);     @imagejpeg($target, $imgThumb, 100);     @chmod($imgThumb, 0606); // 추후 삭제를 위하여 파일모드 변경 }

// 프로그램 : 불당썸 2.0.x // 개 발 자 : 아빠불당 (echo4me@gmail.com) // 라이센스 : 프로그램(이하 불당썸)의 라이센스는 GPL이며, 이프로그램을 발췌 또는 개작하여 판매하는 것은 허용하지 않습니다. //            불당썸의 배포는 sir.co.kr과 opencode.co.kr에서만 할 수 있습니다.

// $file_name   : 파일명 // $width       : 썸네일의 폭 // $height      : 썸네일의 높이 (지정하지 않으면 썸네일의 넓이를 사용) //                * $width, $height에 모두 값이 없으면, 이미지 사이즈 그대로 thumb을 생성 // $is_create   : 썸네일이 이미 있을 때, 새로 생성할지 여부를 결정 // $is_crop     : 세로 높이가 $height를 넘을 때 crop 할 것인지를 결정 //                0 : crop 하지 않습니다 //                1 : 기본 crop //                2 : 중간을 기준으로 crop // $quality     : 썸네일의 quality (jpeg, png에만 해당하며, gif에는 해당 없슴) // $small_thumb : 1 (true)이면, 이미지가 썸네일의 폭/높이보다 작을 때에도 썸을 생성 //                2이면, 이미지가 썸네일의 폭/높이보다 작을 때 확대된 썸을 생성 // $watermark   : 워터마크 출력에 대한 설정 //                $watermark[][filename] - 워터마크 파일명 //                $watermark[location] - center, top, top_left, top_right, bottom, bottom_left, bottom_right //                $watermark[x],$watermark[y] - location에서의 offset // $filter      : php imagefilter, http://kr.php.net/imagefilter">http://kr.php.net/imagefilter //                $filter[type], [arg1] ... [arg4] // $noimg       : $noimg(이미지파일) // $thumb_type  : 저장할 썸네일의 형식 (jpg/gif/png. 나머지는 원본대로) /* thumbnail의 if 로직입니다. 구조화 되지 않고 너무 많은 if를 써버렸습니다. ㅠ..ㅠ...

$width에 값이 있으면     - $height에 값이 있으면        - $width > 이미지크기            - $height > 이미지크기 : 이미지 크기대로 썸을 생성            - else                 - $is_crop : 크롭                 - else : 비율대로 썸을 생성        - else           $ratio로 $height를 구해서,           - $height > $tmp_y : 비율대로 썸 생성 (높이가 좀 부족 합니다) <-- 이부분에서 높이를 맞추고 넓기를 crop하자는 의견도 있어요           - else : 이미지 비율로 조정한 후 높이를 crop     - $height에 값이 없으면 (crop 하지 않습니다)        - $width가 이미지 크기보다 더 크면 : 이미지 크기대로 썸을 생성        - else : 비율대로 썸을 생성

$width에 값이 없으면 (높이로만 정렬하는 갤러리의 경우)     - $height가 이미지 크기보다 더 크면 : 이미지 크기대로 썸을 생성     - else         - $is_crop : crop         - else : 비율대로 썸을 생성 */ function thumbnail($file_name, $width=400, $height=400, $is_create=false, $is_crop=true, $quality=90, $small_thumb=1, $watermark="", $filter="", $noimg="", $thumb_type="") {     //if (!$file_name)     //    return;

    // memory limit 설정 변경     @ini_set("memory_limit", -1);

    // 썸네일 디렉토리     $real_dir = dirname($_SERVER['DOCUMENT_ROOT'] . "/nothing");     $dir = dirname(file_path($file_name));     $file = basename($file_name);

    $thumb_dir = $dir . "/thumb";

    // 썸네일을 저장할 디렉토리     $thumb_path = $thumb_dir . "/" . $width . "x" . $height . "_" . $quality;

    if (!file_exists($thumb_dir)) {         @mkdir($thumb_dir, 0707);         @chmod($thumb_dir, 0707);     }

    if (!file_exists($thumb_path)) {         @mkdir($thumb_path, 0707);         @chmod($thumb_path, 0707);     }

    $source_file = $dir . "/" . $file;

    $size = @getimagesize($source_file);     $size_org = $size;

    // animated gif에 대해서 썸을 만들고 싶으면 코멘트를 풀어주세요. 아래코드는 cpu와 disk access를 크게 유발할 수 있습니다     //if ($size[2] == IMG_GIF && is_ani_gif($file_name)) return;

    // 이미지 파일이 없는 경우     if (!$size[0]) {

        // $nomimg에 설정이 없으면 빈 이미지 파일을 생성         if ($noimg)             return $noimg;         else         {             if (!$width)                 $width = 400;             if (!$height)                 $height = $width;             $thumb_file = $thumb_dir . "/" . $width . "x" . $height . "_noimg.gif";

            if (@file_exists($thumb_file))                 ;             else             {                 $target = imagecreate($width, $height);                                 $bg_color = imagecolorallocate($target, 250, 250, 250);                 $font_color = imagecolorallocate($target, 0, 0, 0);                 $font_size = 12;                 $ttf = "$real_dir/img/han.ttf";                 $text = "no image...";                 $size = imagettfbbox($font_size, 0, $ttf, $text);                 $xsize = abs($size[0]) + abs($size[2])+($padding*2);                 $ysize = abs($size[5]) + abs($size[1])+($padding*2);                 $xloc = $width/2-$xsize/2;                 $yloc = $height/2-$ysize/2;                 imagefttext($target, $font_size, 0, $xloc, $yloc, $font_color, $ttf, $text);                 //imagecopy($target, $target, 0, 0, 0, 0, $width, $height);                 imagegif($target, $thumb_file, $quality);                 @chmod($thumb_file, 0606); // 추후 삭제를 위하여 파일모드 변경             }             return str_replace($real_dir, "", $thumb_file);         }     }

    $thumb_file = $thumb_path . "/" . $file;

    // 썸파일이 있으면서 소스파일보다 생성 날짜가 최근일 때     if (@file_exists($thumb_file)) {         $thumb_time = @filemtime($thumb_file);         $source_time = @filemtime($source_file);         if ($is_create == false && $source_time < $thumb_time) {             return str_replace($real_dir, "", $thumb_file);         }     }

    // $width, $height 값이 모두 없는 경우는 현재 사이즈 그대로 thumb을 생성     if (!$width && !$height)         $width = $size[0];

    // 작은 이미지의 경우에도 썸네일을 생성하는 옵션이 없고, 원본 이미지의 size가 thumb보다 작으면 썸네일을 만들지 않는다 (높이가 지정되지 않으면 pass~!)     if (!$small_thumb && $width >= $size[0] && $height && $height >= $size[1])         return str_replace($real_dir, "", $source_file);

    $is_imagecopyresampled = false;     $is_large = false;

    if ($size[2] == 1)         $source = imagecreatefromgif($source_file);     else if ($size[2] == 2) {         // php.net에서 - As of PHP 5.1.3, if you are dealing with corrupted JPEG images         //               you should set the 'gd.jpeg_ignore_warning' directive to 1 to ignore warnings that could mess up your code.         // 어지간한 경고는 무시하는데, 메모리 부족이 나면 그냥 쥑어 버립니다. 아무런 워닝이나 오류도 없이. 상황종료         @ini_set('gd.jpeg_ignore_warning', 1);

        // $msize=php의 할당메모리, $isize=24bit plain에서 본 필요 메모리         // 메모리가 부족하면 워닝이고 뭐고간에 그냥 죽으므로, 썸을 못 만든다.         $msize = memory_get_usage();         $isize = $size['bits'] / 8 * $size[0] * $size[1];         if ($isize > $msize)             return $file_name;

        $source = imagecreatefromjpeg($source_file);         // jpeg 파일의 오류가 나왔을 때, 워터마크가 있으면 오류생성? - 워터마크 없으면 원본을 그냥 사용 (빈도가 낮으니까)         if (!$source) {             if (trim($watermark) && count($watermark) > 0)                 ;             else                 return $file_name;         }     }     else if ($size[2] == 3)         $source = imagecreatefrompng($source_file);     else if ($size[2] == 6)     {         // bmp 파일은 gif 형식으로 썸네일을 생성         $source = ImageCreateFromBMP($source_file);         $size[2] = 1;     }     else if ($size[2] == 5) {         // psd로 썸네일 만들기         $source = imagecreatefrompsd($source_file);         $size[2] = 1;     } else {         return str_replace($real_dir, "", $source_file);     }

    // 썸네일 확대     if ($small_thumb == 2) {         $size0 = $size[0];         $size1 = $size[1];

        if ($width) {             $size[0] = $width;             $size[1] = (int) $width * ($size1/$size0);         } else if ($height)         {             $size[1] = $height;             $size[0] = (int) $height * ($size0/$size1);         }         else             return str_replace($real_dir, "", $source_file);        

        /*         if ($height && $height > $size[1]) {             $size[1] = $height;             $size[0] = (int) $width*($size[0]/$size[1]);         }         */

        $target = imagecreatetruecolor($size[0], $size[1]);         imagecopyresampled($target, $source, 0, 0, 0, 0, $size[0], $size[1], $size0, $size1);         $source = $target;         unset($target);     }

    if ($width) {         $x = $width;         if ($height) {

            if ($width > $size[0]) {  // $width가 이미지 폭보다 클때 ($width의 resize는 불필요)                 if ($height > $size[1]) {                     $x = $size[0];                     $tmp_y = $size[1];                     $target = imagecreatetruecolor($x, $tmp_y);                     imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]);                 } else {                     if ($is_crop) { // 넘치는 높이를 잘라줘야 합니다                         $x = $size[0];                         $y = $size[1];                         $tmp_y = $height;                         $target = imagecreatetruecolor($x, $tmp_y);                         $tmp_target = imagecreatetruecolor($x, $tmp_y);                         imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $y, $size[0], $size[1]);                         imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $tmp_y);                     } else {                         $y = $height;                         $rate = $y / $size[1];                         $x = (int)($size[0] * $rate);                         $target = imagecreatetruecolor($x, $y);                         imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $y, $size[0], $size[1]);                     }                 }             } else { // $width가 이미지 폭보다 작을 때 (폭의 resize가 필요)                 $y = $height;                 $rate = $x / $size[0];                 $tmp_y = (int)($size[1] * $rate);                 if ($height > $tmp_y) {                     if ($height < $size[1]) {                         if ($is_crop) {     // 높이가 작으므로 이미지의 폭만 crop                             $rate = $y / $size[1];                             $tmp_x = (int)($size[0] * $rate);                             $target = imagecreatetruecolor($x, $y);                             $tmp_target = imagecreatetruecolor($tmp_x, $y);                             imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]);                             // copy하는 위치가 이미지의 수평중심이 되게 조정                             $src_x = (int)(($tmp_x - $x)/2);                             imagecopy($target, $tmp_target, 0, 0, $src_x, 0, $x, $y);                         } else {                             $target = imagecreatetruecolor($x, $tmp_y);                             imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]);                         }                     } else {                         // 썸 생성후의 높이가 최종 높이보다 낮으므로 이미지의 폭만 crop                         if ($is_crop == 1) {          // 좌측에서 부터                             $tmp_x = (int)$size[0];                             $tmp_y = (int)$size[1];                             $target = imagecreatetruecolor($x, $tmp_y);                             imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $x, $tmp_y);                         } else if ($is_crop == 2) {   // 중간에서                             $tmp_x = (int)($size[0]/2) - (int)($x/2);                             $tmp_y = (int)$size[1];                             $target = imagecreatetruecolor($x, $tmp_y);                             imagecopyresampled($target, $source, 0, 0, $tmp_x, 0, $x, $tmp_y, $x, $tmp_y);                         } else {                      // 생각없이 썸 생성                             $target = imagecreatetruecolor($x, $tmp_y);                             imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]);                     }                     }                 } else {                     if ($is_crop) {                         $target = imagecreatetruecolor($x, $y);                         $tmp_target = imagecreatetruecolor($x, $tmp_y);                         imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]);                         imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $y);                     } else {                         $rate = $y / $size[1];                         $tmp_x = (int)($size[0] * $rate);                         $target = imagecreatetruecolor($tmp_x, $y);                         imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]);                     }                 }             }         }         else         { // $height에 값이 없는 경우 (crop은 해당 사항이 없죠? ^^)             if ($width >= $size[0]) { // 썸네일의 폭보다 $width가 더 크면, 이미지의 폭으로 썸에일을 만듭니다 (확대된 썸은 허용않음)                 $x = $size[0];                 $tmp_y = $size[1];             } else {                 $rate = $x / $size[0];                 $tmp_y = (int)($size[1] * $rate);             }                         $target = imagecreatetruecolor($x, $tmp_y);             imagecopyresampled($target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]);         }     }     else // $width는 없고 $height만 있는 경우     {         if ($height > $size[1]) {   // 썸네일의 높이보다 $height가 더 크면, 이미지의 높이로 썸네일을 만듭니다 (확대된 썸은 허용않음)             $y = $size[1];             $tmp_x = $size[0];             $target = imagecreatetruecolor($tmp_x, $y);             imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]);         } else {             $x = $size[0];             $y = $height;             $tmp_y = $size[1];             if ($is_crop) {                 $target = imagecreatetruecolor($x, $y);                 $tmp_target = imagecreatetruecolor($x, $tmp_y);                 imagecopyresampled($tmp_target, $source, 0, 0, 0, 0, $x, $tmp_y, $size[0], $size[1]);                 imagecopy($target, $tmp_target, 0, 0, 0, 0, $x, $tmp_y);             } else {                 $rate = $y / $size[1];                 $tmp_x = (int)($size[0] * $rate);                 $target = imagecreatetruecolor($tmp_x, $y);                 imagecopyresampled($target, $source, 0, 0, 0, 0, $tmp_x, $y, $size[0], $size[1]);             }         }     }

    // 이미지 퀄러티를 재조정     ob_start();     if ($size[2] == 1)         imagegif($target, "", $quality);     else if ($size[2] == 2)         imagejpeg($target, "", $quality);     else if ($size[2] == 3)         imagepng($target, "", round(10 - ($quality / 10))); //imagepng의 퀄리티는 0~9까지 사용 가능합니다 (Lusia). 0(no compression) 입니다     $tmp_image_str = ob_get_contents();     ob_end_clean();     $target = imagecreatefromstring($tmp_image_str);     unset($tmp_image_str);

    // watermark 이미지 넣어주기     if (trim($watermark) && count($watermark) > 0) {         foreach ($watermark as $w1) {             // 파일이름과 디렉토리를 구분             $w1_file = $w1['filename'];             if (!$w1_file) continue;

            $w_dir = dirname(file_path($w1_file));             $w_file = basename($w1_file);                 $w1_file = $w_dir . "/" . $w_file;

            // 워터마크 파일이 없으면 워터마크를 찍지 않습니다             if (!file_exists($w1_file))                 break;

            // 워터마크 이미지의 width, height             $sizew = getimagesize($w1_file);             $wx = $sizew[0];             $wy = $sizew[1];             // watermark 이미지 읽어들이기             if ($sizew[2] == 1)                 $w1_source = imagecreatefromgif($w1_file);             else if ($sizew[2] == 2)                 $w1_source = imagecreatefromjpeg($w1_file);             else if ($sizew[2] == 3)                 $w1_source = imagecreatefrompng($w1_file);

            // $target 이미지의 width, height             $sx = imagesx($target);             $sy = imagesy($target);

            switch ($w1[location]) {               case "center"       :                     $tx = (int)($sx/2 - $wx/2) + $w1[x];                     $ty = (int)($sy/2 - $wy/2) + $w1[y];                     break;               case "top"          :                     $tx = (int)($sx/2 - $wx/2) + $w1[x];                     $ty = $w1[y];                     break;               case "top_left"     :                     $tx = $w1[x];                     $ty = $w1[y];                     break;               case "top_right"    :                     $tx = $sx - $wx - $w1[x];                     $ty = $w1[y];                     break;               case "bottom"       :                     $tx = (int)($sx/2 - $wx/2) + $w1[x];                     $ty = $sy - $w1[y] - $wy;                     break;               case "bottom_left"  :                     $tx = $w1[x];                     $ty = $sy - $w1[y] - $wy;                     break;               case "bottom_right" :               default             :                     $tx = $sx - $w1[x] - $wx;                     $ty = $sy - $w1[y] - $wy;             }             imagecopyresampled($target, $w1_source, $tx, $ty, 0, 0, $wx, $wy, $wx, $wy);         }     }

    // php imagefilter     //if ($filter and $size[2] == 2) { //$size[2] == 2 , jpg만 필터 적용     if ($filter) {         $filter_type = $filter[type];         switch($filter_type) {           case  IMG_FILTER_COLORIZE : imagefilter($target, $filter_type, $filter[arg1], $filter[arg2], $filter[arg3], $filter[arg4]);                                       break;           case  IMG_FILTER_PIXELATE : imagefilter($target, $filter_type, $filter[arg1], $filter[arg2]);                                       break;           case  IMG_FILTER_BRIGHTNESS :           case  IMG_FILTER_CONTRAST :           case  IMG_FILTER_SMOOTH   : imagefilter($target, $filter_type, $filter[arg1]);                                       break;           case  IMG_FILTER_NEGATE   :           case  IMG_FILTER_GRAYSCALE:           case  IMG_FILTER_EDGEDETECT:           case  IMG_FILTER_EMBOSS   :           case  IMG_FILTER_GAUSSIAN_BLUR :           case  IMG_FILTER_SELECTIVE_BLUR:           case  IMG_FILTER_MEAN_REMOVAL:  imagefilter($target, $filter_type);                                           break;           case  99: UnsharpMask4($target, $filter[arg1], $filter[arg2], $filter[arg3]);                                         break;           default                   : ; // 필터 타입이 틀리면 아무것도 안합니다         }     }

    $quality=100;     if ($size[2] == 1 || $thumb_type=="gif")         imagegif($target, $thumb_file, 100);    // gif     else if ($size[2] == 2 || $thumb_type=="jpg")         imagejpeg($target, $thumb_file, 100);   // jpeg     else if ($size[2] == 3 || $thumb_type=="png") {         // Turn off alpha blending and set alpha flag         imagealphablending($target, false);         imagesavealpha($target, true);

        imagepng($target, $thumb_file, 0); //imagepng의 퀄리티는 0~9까지 사용 가능합니다 (Lusia). 0(no compression) 입니다     }     else         imagegif($target, $thumb_file, 100);

    @chmod($thumb_file, 0606); // 추후 삭제를 위하여 파일모드 변경

    // 메모리를 부숴줍니다 - http://kr2.php.net/manual/kr/function.imagedestroy.php">http://kr2.php.net/manual/kr/function.imagedestroy.php     if ($target)         imagedestroy($target);     if ($source)         imagedestroy($source);     if ($tmp_target)         imagedestroy($tmp_target);

    return str_replace($real_dir, "", $thumb_file); }

// php imagefilter for PHP4 - http://mgccl.com/2007/03/02/imagefilter-function-for-php-user-without-bundled-gd">http://mgccl.com/2007/03/02/imagefilter-function-for-php-user-without-bundled-gd // //include this file whenever you have to use imageconvolution... //you can use in your project, but keep the comment below :) //great for any image manipulation library //Made by Chao Xu(Mgccl) 3/1/07 //www.webdevlogs.com //V 1.0 if(!function_exists('imagefilter')){  function imagefilter($source, $var, $arg1 = null, $arg2 = null, $arg3 = null){   #define('IMAGE_FILTER_NEGATE',0);   #define('IMAGE_FILTER_GRAYSCALE',0);   #define('IMAGE_FILTER_BRIGHTNESS',2);   #define('IMAGE_FILTER_CONTRAST',3);   #define('IMAGE_FILTER_COLORIZE',4);   #define('IMAGE_FILTER_EDGEDETECT',5);   #define('IMAGE_FILTER_EMBOSS',6);   #define('IMAGE_FILTER_GAUSSIAN_BLUR',7);   #define('IMAGE_FILTER_SELECTIVE_BLUR',8);   #define('IMAGE_FILTER_MEAN_REMOVAL',9);   #define('IMAGE_FILTER_SMOOTH',10);   $max_y = imagesy($source);   $max_x = imagesx($source);     switch ($var){         case 0:             $y = 0;             while($y<$max_y) {                 $x = 0;                 while($x<$max_x){                     $rgb = imagecolorat($source,$x,$y);                     $r = 255 - (($rgb >> 16) & 0xFF);                     $g = 255 - (($rgb >> 8) & 0xFF);                     $b = 255 - ($rgb & 0xFF);                     $a = $rgb >> 24;                     $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a);                     if ($new_pxl == false){                         $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a);                     }                     imagesetpixel($source,$x,$y,$new_pxl);                     ++$x;                 }                 ++$y;             }             return true;         break;         case 1:             $y = 0;             while($y<$max_y) {                 $x = 0;                 while($x<$max_x){                     $rgb = imagecolorat($source,$x,$y);                     $a = $rgb >> 24;                     $r = ((($rgb >> 16) & 0xFF)*0.299)+((($rgb >> 8) & 0xFF)*0.587)+(($rgb & 0xFF)*0.114);                     $new_pxl = imagecolorallocatealpha($source, $r, $r, $r, $a);                     if ($new_pxl == false){                         $new_pxl = imagecolorclosestalpha($source, $r, $r, $r, $a);                     }                     imagesetpixel($source,$x,$y,$new_pxl);                     ++$x;                 }                 ++$y;             }             return true;         break;         case 2:             $y = 0;             while($y<$max_y) {                 $x = 0;                 while($x<$max_x){                     $rgb = imagecolorat($source,$x,$y);                     $r = (($rgb >> 16) & 0xFF) + $arg1;                     $g = (($rgb >> 8) & 0xFF) + $arg1;                     $b = ($rgb & 0xFF) + $arg1;                     $a = $rgb >> 24;                       $r = ($r > 255)? 255 : (($r < 0)? 0:$r);                     $g = ($g > 255)? 255 : (($g < 0)? 0:$g);                     $b = ($b > 255)? 255 : (($b < 0)? 0:$b);                     $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a);                     if ($new_pxl == false){                         $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a);                     }                     imagesetpixel($source,$x,$y,$new_pxl);                     ++$x;                 }                 ++$y;             }             return true;         break;         case 3:             $contrast = pow((100-$arg1)/100,2);             $y = 0;             while($y<$max_y) {                 $x = 0;                 while($x<$max_x){                     $rgb = imagecolorat($source,$x,$y);                     $a = $rgb >> 24;                     $r = (((((($rgb >> 16) & 0xFF)/255)-0.5)*$contrast)+0.5)*255;                     $g = (((((($rgb >> 8) & 0xFF)/255)-0.5)*$contrast)+0.5)*255;                     $b = ((((($rgb & 0xFF)/255)-0.5)*$contrast)+0.5)*255;                     $r = ($r > 255)? 255 : (($r < 0)? 0:$r);                     $g = ($g > 255)? 255 : (($g < 0)? 0:$g);                     $b = ($b > 255)? 255 : (($b < 0)? 0:$b);                     $new_pxl = imagecolorallocatealpha($source, $r, $g, $b, $a);                     if ($new_pxl == false){                         $new_pxl = imagecolorclosestalpha($source, $r, $g, $b, $a);                     }                     imagesetpixel($source,$x,$y,$new_pxl);                     ++$x;                 }                 ++$y;             }             return true;         break;         case 4:             $x = 0;             while($x<$max_x){                 $y = 0;                 while($y<$max_y){                     $rgb = imagecolorat($source, $x, $y);                     $r = (($rgb >> 16) & 0xFF) + $arg1;                     $g = (($rgb >> 8) & 0xFF) + $arg2;                     $b = ($rgb & 0xFF) + $arg3;                     $a = $rgb >> 24;                     $r = ($r > 255)? 255 : (($r < 0)? 0:$r);                     $g = ($g > 255)? 255 : (($g < 0)? 0:$g);              

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

답변 1개

채택된 답변
+20 포인트
7년 전

불당썸.. 예전에 자주 사용했었는데 정말 오랜만에 보네요.

일단 관리자페이지 > 썸네일파일 일괄삭제 해보시고..

그래도 안 되면 그누5는 자체적으로 썸네일 함수를 제공하고 있는데 썸네일 함수를 그누보드 기본 썸네일 함수로 새로 바꾸는 게 낫지 않을까요.

그누보드5에 있는 기본 갤러리형 최신글 참고하면 그렇게 어렵지 않습니다.

그누보드5 자체 썸네일 함수 관련해서는 팁도 많고 적용도 잘 됩니다.

http://gnustudy.com/bbs/board.php?bo_table=gnu_tip&wr_id=156

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

최선비
7년 전
감사합니다

완벽한 해답을 얻지는 못했지만 일찌감치 방향을 바꿀 수 있을 것 같네요 ^^

귀한 시간 할애해 주셔서 감사합니다 ^^

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

답변을 작성하려면 로그인이 필요합니다.

로그인