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년 전
우와 대단합니다.찾던게 이거였는데... 테스트 해봐야 겠네요.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2030 | 17년 전 | 2786 | ||
| 2029 | 17년 전 | 1593 | ||
| 2028 | 17년 전 | 1343 | ||
| 2027 | 17년 전 | 1606 | ||
| 2026 |
진정한승리
|
17년 전 | 2518 | |
| 2025 | 17년 전 | 1732 | ||
| 2024 | 17년 전 | 2015 | ||
| 2023 | 17년 전 | 1301 | ||
| 2022 |
SE7EN
|
17년 전 | 1036 | |
| 2021 | 17년 전 | 1123 | ||
| 2020 | 17년 전 | 2924 | ||
| 2019 | 17년 전 | 2464 | ||
| 2018 | 17년 전 | 2045 | ||
| 2017 | 17년 전 | 2047 | ||
| 2016 | 17년 전 | 1793 | ||
| 2015 | 17년 전 | 2244 | ||
| 2014 | 17년 전 | 2013 | ||
| 2013 | 17년 전 | 1984 | ||
| 2012 | 17년 전 | 1867 | ||
| 2011 | 17년 전 | 1204 | ||
| 2010 | 17년 전 | 1820 | ||
| 2009 | 17년 전 | 2225 | ||
| 2008 | 17년 전 | 2296 | ||
| 2007 | 17년 전 | 1639 | ||
| 2006 |
Arone
|
17년 전 | 1506 | |
| 2005 |
|
17년 전 | 1353 | |
| 2004 | 17년 전 | 2572 | ||
| 2003 |
suerte
|
17년 전 | 2669 | |
| 2002 |
suerte
|
17년 전 | 2071 | |
| 2001 |
suerte
|
17년 전 | 2416 | |
| 2000 |
|
17년 전 | 2721 | |
| 1999 |
|
17년 전 | 1323 | |
| 1998 |
|
17년 전 | 1189 | |
| 1997 | 17년 전 | 6322 | ||
| 1996 | 17년 전 | 1175 | ||
| 1995 | 17년 전 | 1626 | ||
| 1994 | 17년 전 | 1776 | ||
| 1993 | 17년 전 | 1097 | ||
| 1992 | 17년 전 | 1186 | ||
| 1991 | 17년 전 | 1888 | ||
| 1990 |
sdjsu
|
17년 전 | 1517 | |
| 1989 | 17년 전 | 3613 | ||
| 1988 |
smilesol
|
17년 전 | 1202 | |
| 1987 |
|
17년 전 | 1903 | |
| 1986 | 17년 전 | 1166 | ||
| 1985 | 17년 전 | 1383 | ||
| 1984 | 17년 전 | 2358 | ||
| 1983 | 17년 전 | 2009 | ||
| 1982 | 17년 전 | 1033 | ||
| 1981 | 17년 전 | 1034 | ||
| 1980 | 17년 전 | 1085 | ||
| 1979 |
오렌지76
|
17년 전 | 6041 | |
| 1978 |
오렌지76
|
17년 전 | 5843 | |
| 1977 | 17년 전 | 2025 | ||
| 1976 |
없어씨바라
|
17년 전 | 1020 | |
| 1975 | 17년 전 | 1111 | ||
| 1974 | 17년 전 | 2077 | ||
| 1973 | 17년 전 | 1507 | ||
| 1972 | 17년 전 | 1151 | ||
| 1971 |
smilesol
|
17년 전 | 1180 | |
| 1970 | 17년 전 | 1125 | ||
| 1969 |
smilesol
|
17년 전 | 1051 | |
| 1968 |
소행성블루
|
17년 전 | 3962 | |
| 1967 |
소행성블루
|
17년 전 | 2175 | |
| 1966 | 17년 전 | 1629 | ||
| 1965 |
소행성블루
|
17년 전 | 2765 | |
| 1964 |
고양Ol아빠
|
17년 전 | 1469 | |
| 1963 | 17년 전 | 1152 | ||
| 1962 | 17년 전 | 1169 | ||
| 1961 |
choijinhee
|
17년 전 | 1240 | |
| 1960 | 17년 전 | 1124 | ||
| 1959 | 17년 전 | 1243 | ||
| 1958 |
하이웹솔루션
|
17년 전 | 2402 | |
| 1957 | 17년 전 | 4187 | ||
| 1956 | 17년 전 | 1188 | ||
| 1955 | 17년 전 | 3947 | ||
| 1954 | 17년 전 | 4098 | ||
| 1953 | 17년 전 | 1216 | ||
| 1952 | 17년 전 | 2171 | ||
| 1951 | 17년 전 | 1618 | ||
| 1950 | 17년 전 | 3211 | ||
| 1949 | 17년 전 | 1357 | ||
| 1948 | 17년 전 | 3606 | ||
| 1947 | 17년 전 | 3402 | ||
| 1946 | 17년 전 | 2571 | ||
| 1945 | 17년 전 | 2935 | ||
| 1944 | 17년 전 | 2624 | ||
| 1943 | 17년 전 | 1944 | ||
| 1942 | 17년 전 | 3308 | ||
| 1941 | 17년 전 | 2623 | ||
| 1940 | 17년 전 | 3518 | ||
| 1939 |
|
17년 전 | 1146 | |
| 1938 | 17년 전 | 2245 | ||
| 1937 | 17년 전 | 1318 | ||
| 1936 |
smilesol
|
17년 전 | 1184 | |
| 1935 |
AHEEZII
|
17년 전 | 1057 | |
| 1934 |
smilesol
|
17년 전 | 1042 | |
| 1933 | 17년 전 | 1417 | ||
| 1932 | 17년 전 | 2855 | ||
| 1931 | 17년 전 | 3250 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기