function thumbnail($file, $save_filename, $max_width, $max_height){
$src_img = ImageCreateFromJPEG($file); //JPG파일로부터 이미지를 읽어옵니다
$img_info = getImageSize($file);//원본이미지의 정보를 얻어옵니다
$img_width = $img_info[0];
$img_height = $img_info[1];
if(($img_width/$max_width) == ($img_height/$max_height)){
$dst_width=$max_width;
$dst_height=$max_height;
}elseif(($img_width/$max_width) < ($img_height/$max_height)){
$dst_width=$max_height*($img_width/$img_height);
$dst_height=$max_height;
}else{
$dst_width=$max_width;
$dst_height=$max_width*($img_height/$img_width);
}
$dst_img = imagecreatetruecolor($dst_width, $dst_height); //타겟이미지를 생성합니다
ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $img_width, $img_height);
ImageInterlace($dst_img);
ImageJPEG($dst_img, $save_filename); //실제로 이미지파일을 생성합니다
ImageDestroy($dst_img);
ImageDestroy($src_img);
}
//사용 예문
if($_FILES['Filedata']['name']){
$uploadDir1="../b_img/temp/"; //원본
$uploadDir2="../b_img/$reg_date/"; //썸네일
$uploadFile1="$uploadDir1".iconv("utf-8","euc-kr",$_FILES['Filedata']['name']); //원본경로
$uploadFile2="$uploadDir2".iconv("utf-8","euc-kr",$_FILES['Filedata']['name']); //썸네일경로
//$uploadFile = "$uploadDir". basename($_FILES['Filedata']['name']);
move_uploaded_file($_FILES['Filedata']['tmp_name'],$uploadFile1);
chmod($uploadFile1,0707);
chmod($uploadFile2,0707);
thumbnail($uploadFile1,$uploadFile2,"180","135");
}
$src_img = ImageCreateFromJPEG($file); //JPG파일로부터 이미지를 읽어옵니다
$img_info = getImageSize($file);//원본이미지의 정보를 얻어옵니다
$img_width = $img_info[0];
$img_height = $img_info[1];
if(($img_width/$max_width) == ($img_height/$max_height)){
$dst_width=$max_width;
$dst_height=$max_height;
}elseif(($img_width/$max_width) < ($img_height/$max_height)){
$dst_width=$max_height*($img_width/$img_height);
$dst_height=$max_height;
}else{
$dst_width=$max_width;
$dst_height=$max_width*($img_height/$img_width);
}
$dst_img = imagecreatetruecolor($dst_width, $dst_height); //타겟이미지를 생성합니다
ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $img_width, $img_height);
ImageInterlace($dst_img);
ImageJPEG($dst_img, $save_filename); //실제로 이미지파일을 생성합니다
ImageDestroy($dst_img);
ImageDestroy($src_img);
}
//사용 예문
if($_FILES['Filedata']['name']){
$uploadDir1="../b_img/temp/"; //원본
$uploadDir2="../b_img/$reg_date/"; //썸네일
$uploadFile1="$uploadDir1".iconv("utf-8","euc-kr",$_FILES['Filedata']['name']); //원본경로
$uploadFile2="$uploadDir2".iconv("utf-8","euc-kr",$_FILES['Filedata']['name']); //썸네일경로
//$uploadFile = "$uploadDir". basename($_FILES['Filedata']['name']);
move_uploaded_file($_FILES['Filedata']['tmp_name'],$uploadFile1);
chmod($uploadFile1,0707);
chmod($uploadFile2,0707);
thumbnail($uploadFile1,$uploadFile2,"180","135");
}
[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]
댓글 1개
15년 전
우와 대단합니다.찾던게 이거였는데... 테스트 해봐야 겠네요.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2230 | 16년 전 | 1288 | ||
| 2229 | 16년 전 | 2160 | ||
| 2228 | 16년 전 | 3222 | ||
| 2227 | 16년 전 | 2165 | ||
| 2226 | 16년 전 | 1748 | ||
| 2225 | 16년 전 | 1507 | ||
| 2224 |
|
16년 전 | 2042 | |
| 2223 | 16년 전 | 4723 | ||
| 2222 | 16년 전 | 1405 | ||
| 2221 |
|
16년 전 | 2142 | |
| 2220 |
|
16년 전 | 2131 | |
| 2219 |
|
16년 전 | 2400 | |
| 2218 |
|
16년 전 | 2144 | |
| 2217 |
|
16년 전 | 4434 | |
| 2216 |
|
16년 전 | 2921 | |
| 2215 | 16년 전 | 2862 | ||
| 2214 | 16년 전 | 1594 | ||
| 2213 | 16년 전 | 1235 | ||
| 2212 |
|
16년 전 | 3941 | |
| 2211 |
|
16년 전 | 1613 | |
| 2210 |
|
16년 전 | 1602 | |
| 2209 | 16년 전 | 2107 | ||
| 2208 | 16년 전 | 1878 | ||
| 2207 |
letsgolee
|
16년 전 | 1489 | |
| 2206 |
|
16년 전 | 3913 | |
| 2205 | 16년 전 | 1753 | ||
| 2204 | 16년 전 | 3133 | ||
| 2203 | 16년 전 | 3019 | ||
| 2202 | 16년 전 | 1040 | ||
| 2201 | 16년 전 | 1844 | ||
| 2200 | 16년 전 | 1589 | ||
| 2199 |
|
16년 전 | 1849 | |
| 2198 |
태양의서쪽
|
16년 전 | 2634 | |
| 2197 |
태양의서쪽
|
16년 전 | 3015 | |
| 2196 |
태양의서쪽
|
16년 전 | 3218 | |
| 2195 | 16년 전 | 3324 | ||
| 2194 | 16년 전 | 1459 | ||
| 2193 |
letsgolee
|
16년 전 | 1417 | |
| 2192 | 16년 전 | 2253 | ||
| 2191 | 16년 전 | 1972 | ||
| 2190 |
|
16년 전 | 2287 | |
| 2189 | 16년 전 | 2808 | ||
| 2188 |
Sizkein
|
16년 전 | 3260 | |
| 2187 |
letsgolee
|
16년 전 | 2356 | |
| 2186 |
Sizkein
|
16년 전 | 1632 | |
| 2185 |
Sizkein
|
16년 전 | 3203 | |
| 2184 |
Sizkein
|
16년 전 | 3061 | |
| 2183 | 16년 전 | 3039 | ||
| 2182 | 16년 전 | 3907 | ||
| 2181 | 16년 전 | 2579 | ||
| 2180 |
|
16년 전 | 2401 | |
| 2179 | 16년 전 | 2650 | ||
| 2178 | 16년 전 | 2894 | ||
| 2177 | 17년 전 | 2612 | ||
| 2176 | 17년 전 | 1451 | ||
| 2175 | 17년 전 | 1891 | ||
| 2174 | 17년 전 | 1485 | ||
| 2173 |
|
17년 전 | 1910 | |
| 2172 | 17년 전 | 2507 | ||
| 2171 | 17년 전 | 8691 | ||
| 2170 | 17년 전 | 3149 | ||
| 2169 | 17년 전 | 4236 | ||
| 2168 |
|
17년 전 | 1977 | |
| 2167 | 17년 전 | 3655 | ||
| 2166 |
|
17년 전 | 1546 | |
| 2165 | 17년 전 | 1383 | ||
| 2164 | 17년 전 | 2319 | ||
| 2163 | 17년 전 | 1314 | ||
| 2162 | 17년 전 | 1635 | ||
| 2161 | 17년 전 | 1454 | ||
| 2160 | 17년 전 | 2525 | ||
| 2159 |
inxps
|
17년 전 | 1491 | |
| 2158 |
inxps
|
17년 전 | 1091 | |
| 2157 | 17년 전 | 1220 | ||
| 2156 | 17년 전 | 3093 | ||
| 2155 | 17년 전 | 2165 | ||
| 2154 | 17년 전 | 1970 | ||
| 2153 |
|
17년 전 | 1219 | |
| 2152 |
letsgolee
|
17년 전 | 2453 | |
| 2151 | 17년 전 | 1169 | ||
| 2150 |
아름다운세상
|
17년 전 | 1124 | |
| 2149 |
아름다운세상
|
17년 전 | 1367 | |
| 2148 |
아름다운세상
|
17년 전 | 2732 | |
| 2147 |
|
17년 전 | 2396 | |
| 2146 | 17년 전 | 2482 | ||
| 2145 | 17년 전 | 1183 | ||
| 2144 | 17년 전 | 1300 | ||
| 2143 | 17년 전 | 3241 | ||
| 2142 | 17년 전 | 2830 | ||
| 2141 | 17년 전 | 4107 | ||
| 2140 | 17년 전 | 2256 | ||
| 2139 | 17년 전 | 2347 | ||
| 2138 | 17년 전 | 1394 | ||
| 2137 | 17년 전 | 2513 | ||
| 2136 | 17년 전 | 2200 | ||
| 2135 | 17년 전 | 2959 | ||
| 2134 |
아름다운세상
|
17년 전 | 2468 | |
| 2133 |
Juinjang
|
17년 전 | 1629 | |
| 2132 | 17년 전 | 2429 | ||
| 2131 | 17년 전 | 1588 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기