이미지 리사이징( image resize) 활용 예제
페이지 정보
작성자 휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 댓글 1건 조회 10,854회 작성일 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>";
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 ;
$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'];
$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;
$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 ;
$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 비율대로 리사이징 끝
// 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 비율대로 리사이징
} ?>
첨부파일
- latest.skin.php (4.3K) 86회 다운로드 | DATE : 2008-09-03 23:36:19
관련링크
- http://www.dongto.kr/index.php 4504회 연결
댓글목록
휴먼님의 댓글
휴먼 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 작성일/skin/latest/main_roll/latest.skin.php