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년 전
우와 대단합니다.찾던게 이거였는데... 테스트 해봐야 겠네요.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2730 | 15년 전 | 653 | ||
| 2729 | 15년 전 | 1398 | ||
| 2728 |
|
15년 전 | 930 | |
| 2727 |
용다섯마리
|
15년 전 | 689 | |
| 2726 |
니콜크더만
|
15년 전 | 773 | |
| 2725 |
Insungbyun
|
15년 전 | 834 | |
| 2724 | 15년 전 | 1227 | ||
| 2723 | 15년 전 | 725 | ||
| 2722 | 15년 전 | 737 | ||
| 2721 | 15년 전 | 956 | ||
| 2720 | 15년 전 | 685 | ||
| 2719 |
|
15년 전 | 1427 | |
| 2718 | 15년 전 | 1051 | ||
| 2717 |
디이자이너
|
15년 전 | 2872 | |
| 2716 |
|
15년 전 | 1362 | |
| 2715 | 15년 전 | 654 | ||
| 2714 |
고추장불고기
|
15년 전 | 622 | |
| 2713 | 15년 전 | 787 | ||
| 2712 | 15년 전 | 1261 | ||
| 2711 | 15년 전 | 1188 | ||
| 2710 | 15년 전 | 668 | ||
| 2709 | 15년 전 | 793 | ||
| 2708 |
TWM소프트
|
15년 전 | 981 | |
| 2707 |
|
15년 전 | 1213 | |
| 2706 |
|
15년 전 | 1017 | |
| 2705 | 15년 전 | 997 | ||
| 2704 | 15년 전 | 1190 | ||
| 2703 |
|
15년 전 | 667 | |
| 2702 |
|
15년 전 | 652 | |
| 2701 | 15년 전 | 1058 | ||
| 2700 | 15년 전 | 645 | ||
| 2699 | 15년 전 | 1746 | ||
| 2698 | 15년 전 | 2251 | ||
| 2697 |
|
15년 전 | 821 | |
| 2696 | 15년 전 | 819 | ||
| 2695 | 15년 전 | 1482 | ||
| 2694 |
|
15년 전 | 884 | |
| 2693 | 15년 전 | 977 | ||
| 2692 | 15년 전 | 1386 | ||
| 2691 |
Homepix
|
15년 전 | 1548 | |
| 2690 | 15년 전 | 1650 | ||
| 2689 | 15년 전 | 1089 | ||
| 2688 |
sooram
|
15년 전 | 1758 | |
| 2687 |
terrorboys
|
15년 전 | 1569 | |
| 2686 |
진정한승리
|
15년 전 | 801 | |
| 2685 |
|
15년 전 | 1793 | |
| 2684 |
진정한승리
|
15년 전 | 923 | |
| 2683 |
dannykim
|
15년 전 | 779 | |
| 2682 | 15년 전 | 827 | ||
| 2681 | 15년 전 | 776 | ||
| 2680 | 15년 전 | 945 | ||
| 2679 | 15년 전 | 962 | ||
| 2678 | 15년 전 | 1173 | ||
| 2677 |
|
15년 전 | 3185 | |
| 2676 | 15년 전 | 1755 | ||
| 2675 | 15년 전 | 900 | ||
| 2674 | 15년 전 | 1601 | ||
| 2673 | 15년 전 | 767 | ||
| 2672 | 15년 전 | 905 | ||
| 2671 |
다케미카코
|
15년 전 | 1866 | |
| 2670 | 15년 전 | 1815 | ||
| 2669 | 15년 전 | 857 | ||
| 2668 |
terrorboys
|
15년 전 | 1114 | |
| 2667 | 15년 전 | 1069 | ||
| 2666 | 15년 전 | 1034 | ||
| 2665 | 15년 전 | 1222 | ||
| 2664 | 15년 전 | 953 | ||
| 2663 | 15년 전 | 978 | ||
| 2662 | 15년 전 | 900 | ||
| 2661 | 15년 전 | 1032 | ||
| 2660 | 15년 전 | 945 | ||
| 2659 | 15년 전 | 1543 | ||
| 2658 | 15년 전 | 783 | ||
| 2657 | 15년 전 | 753 | ||
| 2656 | 15년 전 | 1391 | ||
| 2655 | 15년 전 | 1290 | ||
| 2654 | 15년 전 | 1234 | ||
| 2653 | 15년 전 | 804 | ||
| 2652 | 15년 전 | 1595 | ||
| 2651 | 15년 전 | 977 | ||
| 2650 | 15년 전 | 1632 | ||
| 2649 |
windday
|
15년 전 | 1988 | |
| 2648 | 15년 전 | 1415 | ||
| 2647 | 15년 전 | 7609 | ||
| 2646 | 15년 전 | 1036 | ||
| 2645 | 15년 전 | 1257 | ||
| 2644 | 15년 전 | 987 | ||
| 2643 | 15년 전 | 1203 | ||
| 2642 | 15년 전 | 976 | ||
| 2641 | 15년 전 | 1191 | ||
| 2640 |
프리랜서개발자
|
15년 전 | 923 | |
| 2639 | 15년 전 | 2012 | ||
| 2638 | 15년 전 | 1027 | ||
| 2637 | 15년 전 | 933 | ||
| 2636 | 15년 전 | 1421 | ||
| 2635 | 15년 전 | 1315 | ||
| 2634 | 15년 전 | 1043 | ||
| 2633 | 15년 전 | 916 | ||
| 2632 | 15년 전 | 951 | ||
| 2631 | 15년 전 | 1233 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기