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년 전 | 415 | ||
| 7929 | 9년 전 | 335 | ||
| 7928 | 9년 전 | 425 | ||
| 7927 | 9년 전 | 342 | ||
| 7926 | 9년 전 | 670 | ||
| 7925 | 9년 전 | 362 | ||
| 7924 | 9년 전 | 340 | ||
| 7923 | 9년 전 | 351 | ||
| 7922 | 9년 전 | 386 | ||
| 7921 | 9년 전 | 401 | ||
| 7920 | 9년 전 | 323 | ||
| 7919 | 9년 전 | 334 | ||
| 7918 | 9년 전 | 493 | ||
| 7917 | 9년 전 | 338 | ||
| 7916 | 9년 전 | 413 | ||
| 7915 | 9년 전 | 409 | ||
| 7914 | 9년 전 | 420 | ||
| 7913 | 9년 전 | 584 | ||
| 7912 | 9년 전 | 423 | ||
| 7911 | 9년 전 | 369 | ||
| 7910 | 9년 전 | 416 | ||
| 7909 | 9년 전 | 511 | ||
| 7908 | 9년 전 | 432 | ||
| 7907 | 9년 전 | 374 | ||
| 7906 | 9년 전 | 399 | ||
| 7905 | 9년 전 | 379 | ||
| 7904 | 9년 전 | 362 | ||
| 7903 | 9년 전 | 351 | ||
| 7902 | 9년 전 | 564 | ||
| 7901 |
|
9년 전 | 741 | |
| 7900 | 9년 전 | 596 | ||
| 7899 | 9년 전 | 389 | ||
| 7898 | 9년 전 | 391 | ||
| 7897 | 9년 전 | 351 | ||
| 7896 | 9년 전 | 366 | ||
| 7895 | 9년 전 | 470 | ||
| 7894 | 9년 전 | 395 | ||
| 7893 | 9년 전 | 345 | ||
| 7892 | 9년 전 | 403 | ||
| 7891 | 9년 전 | 770 | ||
| 7890 | 9년 전 | 1200 | ||
| 7889 | 9년 전 | 751 | ||
| 7888 |
limsy1987
|
9년 전 | 551 | |
| 7887 | 9년 전 | 554 | ||
| 7886 | 9년 전 | 447 | ||
| 7885 | 9년 전 | 416 | ||
| 7884 | 9년 전 | 415 | ||
| 7883 | 9년 전 | 407 | ||
| 7882 | 9년 전 | 460 | ||
| 7881 | 9년 전 | 445 | ||
| 7880 | 9년 전 | 577 | ||
| 7879 | 9년 전 | 469 | ||
| 7878 | 9년 전 | 1226 | ||
| 7877 | 9년 전 | 754 | ||
| 7876 | 9년 전 | 494 | ||
| 7875 | 9년 전 | 564 | ||
| 7874 |
|
9년 전 | 811 | |
| 7873 | 9년 전 | 524 | ||
| 7872 | 9년 전 | 682 | ||
| 7871 | 9년 전 | 487 | ||
| 7870 | 9년 전 | 612 | ||
| 7869 | 9년 전 | 438 | ||
| 7868 | 9년 전 | 456 | ||
| 7867 | 9년 전 | 434 | ||
| 7866 | 9년 전 | 498 | ||
| 7865 | 9년 전 | 459 | ||
| 7864 | 9년 전 | 518 | ||
| 7863 | 9년 전 | 515 | ||
| 7862 | 9년 전 | 468 | ||
| 7861 | 9년 전 | 643 | ||
| 7860 | 9년 전 | 634 | ||
| 7859 | 9년 전 | 416 | ||
| 7858 | 9년 전 | 707 | ||
| 7857 | 9년 전 | 1082 | ||
| 7856 | 9년 전 | 530 | ||
| 7855 | 9년 전 | 757 | ||
| 7854 | 9년 전 | 733 | ||
| 7853 | 9년 전 | 587 | ||
| 7852 | 9년 전 | 512 | ||
| 7851 | 9년 전 | 511 | ||
| 7850 | 9년 전 | 590 | ||
| 7849 | 9년 전 | 359 | ||
| 7848 | 9년 전 | 413 | ||
| 7847 | 9년 전 | 657 | ||
| 7846 | 9년 전 | 461 | ||
| 7845 | 9년 전 | 424 | ||
| 7844 | 9년 전 | 395 | ||
| 7843 | 9년 전 | 424 | ||
| 7842 | 9년 전 | 404 | ||
| 7841 | 9년 전 | 388 | ||
| 7840 | 9년 전 | 409 | ||
| 7839 | 9년 전 | 438 | ||
| 7838 | 9년 전 | 520 | ||
| 7837 | 9년 전 | 358 | ||
| 7836 | 9년 전 | 401 | ||
| 7835 | 9년 전 | 475 | ||
| 7834 |
|
9년 전 | 1196 | |
| 7833 | 9년 전 | 438 | ||
| 7832 | 9년 전 | 422 | ||
| 7831 | 9년 전 | 570 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기