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

이미지 가로 세로 긴쪽 기준 썸네일 생성 하려면 채택완료

어떻게 해야 할까요..?

 

이미지 원본비율 유지하면서

가로 세로 긴쪽 기준으로 썸네일을 생성하려는데 잘 안되네요..

 

그래서 g4에서 사용하던 썸네일 생성 소스를 만지작 ...

 

        $file = $list[$i][file][0][path].'/'.$list[$i][file][0][file];         if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file))         {             $size = getimagesize($file);

 

파일명은 나오는데

$size 를 불러오지 못하네요..

 

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

답변 4개

위와 같은 건입니다.

소스를 어떤 부분에 넣어야 하는지 좀 부탁드립니다.

 

제가사용하는

list.skin.php 파일 입니다

// 제목길이 잘 맞추세요. $thu_width = '140';  //썸네일 폭 $thu_height = '120'; //썸네일 높이 $thu_quality = '100'; //썸네일 퀄리티_100 이하

if (!function_exists("imagecopyresampled")) alert("GD 2.0.1 이상 버전이 설치되어 있어야 사용할 수 있는 갤러리 게시판 입니다.");

$data_path = $g4[path]."/data/file/$bo_table"; $thumb_path = $data_path.'/thumb';

@mkdir($thumb_path, 0707); @chmod($thumb_path, 0707);

$mod = $board[bo_gallery_cols]; $td_width = (int)(100 / $mod);

// 선택옵션으로 인해 셀합치기가 가변적으로 변함 $colspan = 5; if ($is_category) $colspan++; if ($is_checkbox) $colspan++; if ($is_good) $colspan++; if ($is_nogood) $colspan++;

// 제목이 두줄로 표시되는 경우 이 코드를 사용해 보세요. // 제목

/* $tmp_bo_table = "cm_gallery_request"; $tmp_write_table = $g4[write_prefix] . $tmp_bo_table; $sql = " select wr_id, wr_subject from $tmp_write_table where wr_is_comment = 0 and wr_comment = 0 order by wr_id desc "; $result = sql_query($sql); for ($i=0; $row=sql_fetch_array($result); $i++) {     echo "

"; } */ ?>

       
                Total                

";     $image = $list[$i][file][0][file];     $img = "";     $thumb = $thumb_path.'/'.$list[$i][wr_id];     if (!file_exists($thumb))     {         $file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];         if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file))         {             $size = @getimagesize($file);             if ($size[2] == 1)                 $src = imagecreatefromgif($file);             else if ($size[2] == 2)                 $src = imagecreatefromjpeg($file);             else if ($size[2] == 3)                 $src = imagecreatefrompng($file);             else                 continue;

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

            if ($height < $thu_height)                 $dst = imagecreatetruecolor($thu_width, $height);             else                 $dst = imagecreatetruecolor($thu_width, $thu_height);             imagecopyresampled($dst, $src, 0, 0, 0, 0, $thu_width, $height, $size[0], $size[1]);             imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $thu_quality);             chmod($thumb_path.'/'.$list[$i][wr_id], 0606);         }     }

    if (file_exists($thumb))         $img = "";

    $style = "";     if ($list[$i][icon_new])         $style = " style='font-weight:bold;' ";     $subject = "".cut_str($list[$i][subject],20)."";

    $comment_cnt = "";     if ($list[$i][comment_cnt])         $comment_cnt = " {$list[$i][comment_cnt]}";

    $bg = "";  //새글?      if ($list[$i][icon_new])          $bg="thumb_1_2.gif";       else          $bg="thumb_1.gif";

    echo "

\n";

}

// 나머지 td $cnt = $i%$mod; if ($cnt)     for ($i=$cnt; $i<$mod; $i++)         echo "

"; ?>

"; } ?>
\n";     echo "\n";

    echo "

\n";    echo "\n";     echo "\n";

    echo "

$img
$subject
 
height=1 bgcolor=#E7E7E7>
게시물이 없습니다.
bgcolor="#5686AD" height=1>

   
        "; } ?>         ", $write_pages);         $write_pages = str_replace("이전", "", $write_pages);         $write_pages = str_replace("다음", "", $write_pages);         $write_pages = str_replace("맨끝", "", $write_pages);         $write_pages = preg_replace("/([0-9]*)<\/span>/", "$1", $write_pages);         $write_pages = preg_replace("/([0-9]*)<\/b>/", "$1", $write_pages);         ?>                 "; } ?>    

       
                                                                                                                and         or                

 

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

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

$w = (int)$w; //소수점이하 버림 $h = (int)$h;

 

요거 추가해 주세요.. 

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

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

원본 비율 유지하면서 가로 세로 최대 사이즈 지정 썸네일 생성..  (세로로 너무 긴 사진이 있을 경우) $tw_max = 150; //썸네일 가로 최대 사이즈 - 환경설정 무시 $th_max = 110; //썸네일 세로 최대 사이즈 if ($t_w < $tw_max){  if ($t_h > $th_max){         $h = $th_max ;         $w = ceil( $t_w * ( $th_max / $t_h ) );       } else {         $h = $t_h;         $w = $t_w;       } }else{      if (( $t_h / $t_w ) > ($th_max / $tw_max)){         $h = $th_max ;         $w = ceil( $t_w * ( $th_max / $t_h ) );         }else{         $w = $tw_max ;         $h = ceil( $t_h * ( $tw_max / $t_w ) );  } }

 

 


 

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

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

해결 했습니다.

잘 되는지 좀 봐주세요.. 

list.skin.php $t_w = $list[$i][file][0][image_width]; //원본파일 사이즈 $t_h = $list[$i][file][0][image_height]; $t_max = 150; //썸네일 최대 사이즈 - 환경설정 무시 if ($t_w < $t_max){  if ($t_h > $t_max){         $h = $t_max ;         $w = ceil( $t_w * ( $t_max / $t_h ) );       } else {         $h = $t_h;         $w = $t_w;       }  }else{      if (( $t_h / $t_w ) > ($t_max / $t_max)){         $h = $t_max ;         $w = ceil( $t_w * ( $t_max / $t_h ) );         }else{         $w = $t_max ;         $h = ceil( $t_h * ( $t_max / $t_w ) );  } }     $thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $w, $h); //  $thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height']);      if($thumb['src']) {      $img_content = ''.$thumb['alt'].''; //   $img_content = ''.$thumb['alt'].''; 

 

 

 

 


 

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

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

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

로그인

전체 질문 목록

🐛 버그신고