이미지 리사이징( image resize) 활용 예제 > 웹디자인 Tip

본문 바로가기
 

이미지 리사이징( image resize) 활용 예제

페이지 정보

작성자 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 댓글 1건 조회 10,817회 작성일 08-09-03 23:31

본문

<? $image = urlencode($list[$i][file][0][file]); // 첫번째 파일이 이미지라면
          if (preg_match("/\.(gif|jpg|png)$/i", $image) && file_exists("$g4[path]/data/file/$bo_table/$image")) {
     //echo "<a href='{$list[$i][href]}'><img src='$g4[path]/data/file/$bo_table/$image' width='{$img_w}' height='{$img_h}' border='0'></a>";
     // image 사이즈 정보
     $size = getimagesize("$g4[path]/data/file/$bo_table/$image");
     $width = $size[0] ;
        $height = $size[1] ;
           //echo $width ;
           //echo "<br>" ;
           //echo $height ;
     // image 비율대로 리사이징 시작
      $max_width = 100; // $_REQUEST['max_width'];
      $max_height = 80 ; // $_REQUEST['max_height'];
      if (!$max_width)
        $max_width = 100;
      if (!$max_height)
        $max_height = 80;
 
      $x_ratio = $max_width / $width;
      $y_ratio = $max_height / $height;
      if ( ($width <= $max_width) && ($height <= $max_height) ) {
        $tn_width = $width;
        $tn_height = $height;
      }
      else if (($x_ratio * $height) < $max_height) {
        $tn_height = ceil($x_ratio * $height);
        $tn_width = $max_width;
      }
      else {
        $tn_width = ceil($y_ratio * $width);
        $tn_height = $max_height;
      }
     $img_w = $tn_width ;
     $img_h = $tn_height ;
     echo "<a href='{$list[$i][href]}'><img src='$g4[path]/data/file/$bo_table/$image' width='{$img_w}' height='{$img_h}' border='0'></a>";
     // image 비율대로 리사이징 끝

          } else {
     echo "<a href='{$list[$i][href]}'><img src='$latest_skin_path/img/no_img.gif' width='{$img_w}' height='{$img_h}' border='0'></a>";
      // image 비율대로 리사이징
     //$size = getimagesize('http://www.dongto.kr/skin/latest/main_roll/img/no_img.gif');
     //$width = $size[0] ;
          //$height = $size[1] ;
         //echo $width ;
         //echo "<br>" ;
         //echo $height ;
     //$img_h = (int)($size[1] * $rate);
     // image 비율대로 리사이징
    } ?>

첨부파일

댓글목록

Total 17건 1 페이지
웹디자인 Tip 목록
번호 제목 글쓴이 조회 날짜
17 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 17367 12-02
16 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 16651 04-10
15 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 16560 08-04
14 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 16240 06-17
13 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 16092 07-29
12 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 15871 09-19
11 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 15660 11-23
10 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 15378 07-16
9 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 15177 07-29
8 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 14988 11-02
7 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 13978 09-03
열람중 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 10818 09-03
5 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9711 07-16
4 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9453 07-16
3 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9426 04-10
2 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9252 04-29
1 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9206 07-16
게시물 검색