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년 전
우와 대단합니다.찾던게 이거였는데... 테스트 해봐야 겠네요.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2330 | 16년 전 | 5071 | ||
| 2329 | 16년 전 | 2306 | ||
| 2328 | 16년 전 | 3404 | ||
| 2327 | 16년 전 | 2640 | ||
| 2326 | 16년 전 | 1558 | ||
| 2325 | 16년 전 | 5359 | ||
| 2324 | 16년 전 | 2473 | ||
| 2323 | 16년 전 | 5966 | ||
| 2322 | 16년 전 | 1939 | ||
| 2321 | 16년 전 | 4019 | ||
| 2320 | 16년 전 | 3033 | ||
| 2319 |
|
16년 전 | 2216 | |
| 2318 |
데니크레인
|
16년 전 | 2236 | |
| 2317 | 16년 전 | 4418 | ||
| 2316 | 16년 전 | 3306 | ||
| 2315 | 16년 전 | 2835 | ||
| 2314 | 16년 전 | 2964 | ||
| 2313 | 16년 전 | 2079 | ||
| 2312 | 16년 전 | 1768 | ||
| 2311 | 16년 전 | 1678 | ||
| 2310 | 16년 전 | 1398 | ||
| 2309 | 16년 전 | 1670 | ||
| 2308 | 16년 전 | 1903 | ||
| 2307 | 16년 전 | 1600 | ||
| 2306 |
|
16년 전 | 4853 | |
| 2305 | 16년 전 | 3829 | ||
| 2304 | 16년 전 | 1790 | ||
| 2303 | 16년 전 | 1534 | ||
| 2302 | 16년 전 | 2272 | ||
| 2301 | 16년 전 | 4536 | ||
| 2300 | 16년 전 | 3560 | ||
| 2299 | 16년 전 | 2589 | ||
| 2298 | 16년 전 | 4361 | ||
| 2297 | 16년 전 | 3229 | ||
| 2296 | 16년 전 | 1370 | ||
| 2295 |
|
16년 전 | 1386 | |
| 2294 |
|
16년 전 | 2041 | |
| 2293 | 16년 전 | 1890 | ||
| 2292 | 16년 전 | 2566 | ||
| 2291 | 16년 전 | 2235 | ||
| 2290 | 16년 전 | 1372 | ||
| 2289 | 16년 전 | 4393 | ||
| 2288 | 16년 전 | 1479 | ||
| 2287 | 16년 전 | 1792 | ||
| 2286 | 16년 전 | 2202 | ||
| 2285 |
|
16년 전 | 3848 | |
| 2284 |
|
16년 전 | 2739 | |
| 2283 |
|
16년 전 | 1494 | |
| 2282 | 16년 전 | 4025 | ||
| 2281 |
|
16년 전 | 1403 | |
| 2280 | 16년 전 | 1589 | ||
| 2279 | 16년 전 | 1247 | ||
| 2278 | 16년 전 | 1714 | ||
| 2277 | 16년 전 | 1619 | ||
| 2276 | 16년 전 | 1628 | ||
| 2275 | 16년 전 | 1426 | ||
| 2274 | 16년 전 | 2187 | ||
| 2273 | 16년 전 | 1836 | ||
| 2272 |
|
16년 전 | 1982 | |
| 2271 | 16년 전 | 2197 | ||
| 2270 |
a1system
|
16년 전 | 1487 | |
| 2269 | 16년 전 | 2317 | ||
| 2268 | 16년 전 | 2260 | ||
| 2267 | 16년 전 | 4538 | ||
| 2266 |
|
16년 전 | 1296 | |
| 2265 | 16년 전 | 1054 | ||
| 2264 |
잠자리똥꾸멍
|
16년 전 | 2013 | |
| 2263 |
태양의서쪽
|
16년 전 | 1980 | |
| 2262 |
태양의서쪽
|
16년 전 | 1522 | |
| 2261 |
태양의서쪽
|
16년 전 | 2046 | |
| 2260 |
|
16년 전 | 2278 | |
| 2259 | 16년 전 | 1389 | ||
| 2258 | 16년 전 | 1739 | ||
| 2257 | 16년 전 | 1921 | ||
| 2256 | 16년 전 | 1014 | ||
| 2255 | 16년 전 | 1689 | ||
| 2254 | 16년 전 | 1406 | ||
| 2253 | 16년 전 | 1920 | ||
| 2252 |
freedays
|
16년 전 | 1326 | |
| 2251 | 16년 전 | 2202 | ||
| 2250 | 16년 전 | 1880 | ||
| 2249 | 16년 전 | 5871 | ||
| 2248 | 16년 전 | 1913 | ||
| 2247 | 16년 전 | 3686 | ||
| 2246 | 16년 전 | 1468 | ||
| 2245 |
|
16년 전 | 1759 | |
| 2244 |
|
16년 전 | 2076 | |
| 2243 | 16년 전 | 2611 | ||
| 2242 | 16년 전 | 2311 | ||
| 2241 | 16년 전 | 2759 | ||
| 2240 | 16년 전 | 2998 | ||
| 2239 | 16년 전 | 3029 | ||
| 2238 |
|
16년 전 | 1826 | |
| 2237 |
|
16년 전 | 1541 | |
| 2236 |
|
16년 전 | 1419 | |
| 2235 | 16년 전 | 1727 | ||
| 2234 | 16년 전 | 1211 | ||
| 2233 | 16년 전 | 1960 | ||
| 2232 |
|
16년 전 | 1733 | |
| 2231 | 16년 전 | 1609 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기