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

본문 바로가기
 

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

페이지 정보

작성자 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 댓글 1건 조회 10,798회 작성일 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 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 15636 11-23
16 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9230 04-29
15 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 16613 04-10
14 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9405 04-10
13 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 15149 07-29
12 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 16056 07-29
11 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 17337 12-02
10 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 14961 11-02
9 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 16537 08-04
8 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 16211 06-17
7 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 15841 09-19
열람중 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 10799 09-03
5 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 13953 09-03
4 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 15336 07-16
3 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9691 07-16
2 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9187 07-16
1 no_profile 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9436 07-16
게시물 검색