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년 전
우와 대단합니다.찾던게 이거였는데... 테스트 해봐야 겠네요.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 460 | ||
| 7929 | 9년 전 | 394 | ||
| 7928 | 9년 전 | 472 | ||
| 7927 | 9년 전 | 379 | ||
| 7926 | 9년 전 | 689 | ||
| 7925 | 9년 전 | 407 | ||
| 7924 | 9년 전 | 390 | ||
| 7923 | 9년 전 | 380 | ||
| 7922 | 9년 전 | 414 | ||
| 7921 | 9년 전 | 433 | ||
| 7920 | 9년 전 | 343 | ||
| 7919 | 9년 전 | 352 | ||
| 7918 | 9년 전 | 507 | ||
| 7917 | 9년 전 | 359 | ||
| 7916 | 9년 전 | 446 | ||
| 7915 | 9년 전 | 454 | ||
| 7914 | 9년 전 | 468 | ||
| 7913 | 9년 전 | 639 | ||
| 7912 | 9년 전 | 468 | ||
| 7911 | 9년 전 | 398 | ||
| 7910 | 9년 전 | 447 | ||
| 7909 | 9년 전 | 555 | ||
| 7908 | 9년 전 | 494 | ||
| 7907 | 9년 전 | 429 | ||
| 7906 | 9년 전 | 449 | ||
| 7905 | 9년 전 | 417 | ||
| 7904 | 9년 전 | 405 | ||
| 7903 | 9년 전 | 405 | ||
| 7902 | 9년 전 | 593 | ||
| 7901 |
|
9년 전 | 767 | |
| 7900 | 9년 전 | 650 | ||
| 7899 | 9년 전 | 432 | ||
| 7898 | 9년 전 | 430 | ||
| 7897 | 9년 전 | 390 | ||
| 7896 | 9년 전 | 407 | ||
| 7895 | 9년 전 | 523 | ||
| 7894 | 9년 전 | 435 | ||
| 7893 | 9년 전 | 408 | ||
| 7892 | 9년 전 | 446 | ||
| 7891 | 9년 전 | 808 | ||
| 7890 | 9년 전 | 1231 | ||
| 7889 | 9년 전 | 766 | ||
| 7888 |
limsy1987
|
9년 전 | 578 | |
| 7887 | 9년 전 | 615 | ||
| 7886 | 9년 전 | 503 | ||
| 7885 | 9년 전 | 473 | ||
| 7884 | 9년 전 | 463 | ||
| 7883 | 9년 전 | 473 | ||
| 7882 | 9년 전 | 527 | ||
| 7881 | 9년 전 | 501 | ||
| 7880 | 9년 전 | 621 | ||
| 7879 | 9년 전 | 510 | ||
| 7878 | 9년 전 | 1279 | ||
| 7877 | 9년 전 | 810 | ||
| 7876 | 9년 전 | 550 | ||
| 7875 | 9년 전 | 615 | ||
| 7874 |
|
9년 전 | 830 | |
| 7873 | 9년 전 | 552 | ||
| 7872 | 9년 전 | 717 | ||
| 7871 | 9년 전 | 530 | ||
| 7870 | 9년 전 | 649 | ||
| 7869 | 9년 전 | 470 | ||
| 7868 | 9년 전 | 505 | ||
| 7867 | 9년 전 | 503 | ||
| 7866 | 9년 전 | 567 | ||
| 7865 | 9년 전 | 506 | ||
| 7864 | 9년 전 | 570 | ||
| 7863 | 9년 전 | 559 | ||
| 7862 | 9년 전 | 522 | ||
| 7861 | 9년 전 | 694 | ||
| 7860 | 9년 전 | 670 | ||
| 7859 | 9년 전 | 445 | ||
| 7858 | 9년 전 | 752 | ||
| 7857 | 9년 전 | 1140 | ||
| 7856 | 9년 전 | 571 | ||
| 7855 | 9년 전 | 804 | ||
| 7854 | 9년 전 | 754 | ||
| 7853 | 9년 전 | 650 | ||
| 7852 | 9년 전 | 567 | ||
| 7851 | 9년 전 | 563 | ||
| 7850 | 9년 전 | 637 | ||
| 7849 | 9년 전 | 405 | ||
| 7848 | 9년 전 | 470 | ||
| 7847 | 9년 전 | 716 | ||
| 7846 | 9년 전 | 501 | ||
| 7845 | 9년 전 | 470 | ||
| 7844 | 9년 전 | 439 | ||
| 7843 | 9년 전 | 480 | ||
| 7842 | 9년 전 | 463 | ||
| 7841 | 10년 전 | 430 | ||
| 7840 | 10년 전 | 447 | ||
| 7839 | 10년 전 | 493 | ||
| 7838 | 10년 전 | 555 | ||
| 7837 | 10년 전 | 385 | ||
| 7836 | 10년 전 | 444 | ||
| 7835 | 10년 전 | 522 | ||
| 7834 |
|
10년 전 | 1228 | |
| 7833 | 10년 전 | 489 | ||
| 7832 | 10년 전 | 463 | ||
| 7831 | 10년 전 | 624 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기