게시판 썸네일 관련 코드 질문... ㅡㅜ > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

게시판 썸네일 관련 코드 질문... ㅡㅜ 정보

게시판 썸네일 관련 코드 질문... ㅡㅜ

본문

글 목록에 썸네일 이미지가 들어가는 게시판을 다운받고 수정중에 있습니다.
그런데 세로 사진의 썸네일 이미지는 이글에 첨부한 사진처럼 사진의 제일 윗부분만 표시되서 보기가 좋지 않네요..
아래는 썸네일 이미지 만드는 코드 입니다. 어느 곳을 수정해야될지좀 알려주세요 ㅡㅜ
세로이미지의 썸네일을 만들때 축소된사진의 가운데에서 조금 윗부분을 잘라서 썸네일로 만들고싶습니다.
(세로인물전신사진일경우 머리와 상체가 썸네일에 들어갈수있도록..)
부탁드려요 ㅠㅠ
 
 
<!--이미지 시작-->
 <td align="center" width="210"><?
      $img = "<img src='$board_skin_path/img/no_img.gif' border=0 title='이미지 없음'>";
      //$thumb = $thumb_path.'/'.$list[$i][wr_id];
      $thumb = $thumb_path.'/'.$list[$i][file][0][file];
      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 = $thumb_width / $size[0];
          $height = (int)($size[1] * $rate);
          if ($height < $thumb_height)
            $dst = imagecreatetruecolor($thumb_width, $height);
          else
            $dst = imagecreatetruecolor($thumb_width, $thumb_height);
          imagecopyresampled($dst, $src, 0, 0, 0, 0, $thumb_width, $height, $size[0], $size[1]);
          imagejpeg($dst, $thumb_path.'/'.$list[$i][file][0][file], $thumb_quality);
          chmod($thumb_path.'/'.$list[$i][file][0][file], 0606);
          imagejpeg($dst, $thumb_path.'/'.$list[$i][wr_id], $thumb_quality);
          chmod($thumb_path.'/'.$list[$i][wr_id], 0606);
        }
      }
      if (file_exists($thumb) && $list[$i][file][0][file]) {
        echo "<a href='{$list[$i][href]}'><img src='{$thumb}' width='{$thumb_width}' height='{$thumb_height}' align='absmiddle' border='0'></a>";
      } else {
        echo "";
      }
    ?></td>  <!--이미지 끝-->

댓글 전체

아래코드를 참고해 보세요.
만일 세로크기가 가로보다 클경우 정해진 사이즈(일정 비율)로 썸네일을 생성하는 소스입니다.
참고하시면 원하시는 대로 만드실 수 있을거예요.
현재 제가 사용하고 있는 소스입니다.
즐거운 추석되세요.
      <?
      for ($i=0; $i<count($list); $i++) {
        $img = "<img src='$board_skin_path/img/noimage.gif' border=0 title='이미지 없음'>";
        $thumb = $thumb_path.'/'.$list[$i][wr_id];
        $file = $list[$i][file][0][path] .'/'. $list[$i][file][0][file];
       
        if (!file_exists($thumb)) {
         
          if (preg_match("/\.(jpg|gif|png)$/i", $file) && file_exists($file)) {
            $thumb_file = "{$thumb_path}/{$list[$i][wr_id]}";
            $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;
           
            if ($size[0] > $size[1]) {
             
                $rate = $board[bo_1] / $size[0];
                $height = (int)($size[1] * $rate);
                $img_width = $board[bo_1];
                $img_height = $height;
               
                $rate1 = $img2_width / $size[0];
                $height1 = (int)($size[1] * $rate1);
                $img2_width = $img2_width;
                $img2_height = $height1;
           
            } else {
             
                $rate = $board[bo_1] / $size[1];
                $width = (int)($size[0] * $rate);
                $img_width = $width;
                $img_height = $board[bo_1];
               
                $rate1 = $img2_height / $size[1];
                $width1 = (int)($size[0] * $rate1);
                $img2_width = $width1;
                $img2_height = $img2_height;
            }
            createThumb2($img_width, $img_height, $file, $thumb, $list[$i][mb_id]);
           
            $thumb_file = "{$thumb_path}/{$list[$i][wr_id]}_{$img2_width}x{$img2_height}";
            createThumb($img2_width, $img2_height, $file, $thumb_file);
          }
        }
       
        if (file_exists($file)) {
          $size = getimagesize($file);
         
          if($size[0] > $size[1]) {
            $rate = $board[bo_1] / $size[0];
            $height = (int)($size[1] * $rate);
            $img_width = $board[bo_1];
            $img_height = $height;
           
            $thumb_rate = 50 / $size[0];
            $img2_width = 50;
            $img2_height = (int)($size[1] * $thumb_rate);
           
            $layer_rate = 250 / $size[0];
            $lay_width = 250;
            $lay_height = (int)($size[1] * $layer_rate);
          } else {
            $rate = $board[bo_1] / $size[1];
            $width = (int)($size[0] * $rate);
            $img_width = $width;
            $img_height = $board[bo_1];
           
            $thumb_rate = 50 / $size[1];
            $img2_width = (int)($size[0] * $thumb_rate);
            $img2_height = 50;
           
            $layer_rate = 250 / $size[1];
            $lay_width = (int)($size[0] * $layer_rate);
            $lay_height = 250;
          }
       
        $img = "<img src='$file' width='{$img2_width}' height='{$img2_height}' align=center style='margin-right:5px; border:1 #222222 solid;' onmouseover=\"overView('$file','{$lay_width}','{$lay_height}');\" onmouseout=\"overViewClose();\">";
        }
        ?>
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

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