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년 전
우와 대단합니다.찾던게 이거였는데... 테스트 해봐야 겠네요.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2230 | 16년 전 | 1292 | ||
| 2229 | 16년 전 | 2161 | ||
| 2228 | 16년 전 | 3226 | ||
| 2227 | 16년 전 | 2169 | ||
| 2226 | 16년 전 | 1755 | ||
| 2225 | 16년 전 | 1513 | ||
| 2224 |
|
16년 전 | 2046 | |
| 2223 | 16년 전 | 4730 | ||
| 2222 | 16년 전 | 1411 | ||
| 2221 |
|
16년 전 | 2146 | |
| 2220 |
|
16년 전 | 2136 | |
| 2219 |
|
16년 전 | 2407 | |
| 2218 |
|
16년 전 | 2147 | |
| 2217 |
|
16년 전 | 4440 | |
| 2216 |
|
16년 전 | 2928 | |
| 2215 | 16년 전 | 2867 | ||
| 2214 | 16년 전 | 1602 | ||
| 2213 | 16년 전 | 1250 | ||
| 2212 |
|
16년 전 | 3949 | |
| 2211 |
|
16년 전 | 1621 | |
| 2210 |
|
16년 전 | 1617 | |
| 2209 | 16년 전 | 2114 | ||
| 2208 | 16년 전 | 1887 | ||
| 2207 |
letsgolee
|
16년 전 | 1495 | |
| 2206 |
|
16년 전 | 3923 | |
| 2205 | 16년 전 | 1763 | ||
| 2204 | 16년 전 | 3136 | ||
| 2203 | 16년 전 | 3024 | ||
| 2202 | 16년 전 | 1048 | ||
| 2201 | 16년 전 | 1844 | ||
| 2200 | 16년 전 | 1596 | ||
| 2199 |
|
16년 전 | 1856 | |
| 2198 |
태양의서쪽
|
16년 전 | 2645 | |
| 2197 |
태양의서쪽
|
16년 전 | 3027 | |
| 2196 |
태양의서쪽
|
16년 전 | 3228 | |
| 2195 | 16년 전 | 3328 | ||
| 2194 | 16년 전 | 1466 | ||
| 2193 |
letsgolee
|
16년 전 | 1423 | |
| 2192 | 16년 전 | 2258 | ||
| 2191 | 17년 전 | 1976 | ||
| 2190 |
|
17년 전 | 2290 | |
| 2189 | 17년 전 | 2811 | ||
| 2188 |
Sizkein
|
17년 전 | 3261 | |
| 2187 |
letsgolee
|
17년 전 | 2359 | |
| 2186 |
Sizkein
|
17년 전 | 1637 | |
| 2185 |
Sizkein
|
17년 전 | 3208 | |
| 2184 |
Sizkein
|
17년 전 | 3063 | |
| 2183 | 17년 전 | 3042 | ||
| 2182 | 17년 전 | 3919 | ||
| 2181 | 17년 전 | 2586 | ||
| 2180 |
|
17년 전 | 2406 | |
| 2179 | 17년 전 | 2654 | ||
| 2178 | 17년 전 | 2898 | ||
| 2177 | 17년 전 | 2617 | ||
| 2176 | 17년 전 | 1453 | ||
| 2175 | 17년 전 | 1897 | ||
| 2174 | 17년 전 | 1495 | ||
| 2173 |
|
17년 전 | 1924 | |
| 2172 | 17년 전 | 2524 | ||
| 2171 | 17년 전 | 8709 | ||
| 2170 | 17년 전 | 3159 | ||
| 2169 | 17년 전 | 4251 | ||
| 2168 |
|
17년 전 | 1989 | |
| 2167 | 17년 전 | 3659 | ||
| 2166 |
|
17년 전 | 1554 | |
| 2165 | 17년 전 | 1388 | ||
| 2164 | 17년 전 | 2324 | ||
| 2163 | 17년 전 | 1319 | ||
| 2162 | 17년 전 | 1641 | ||
| 2161 | 17년 전 | 1460 | ||
| 2160 | 17년 전 | 2530 | ||
| 2159 |
inxps
|
17년 전 | 1501 | |
| 2158 |
inxps
|
17년 전 | 1096 | |
| 2157 | 17년 전 | 1228 | ||
| 2156 | 17년 전 | 3107 | ||
| 2155 | 17년 전 | 2175 | ||
| 2154 | 17년 전 | 1978 | ||
| 2153 |
|
17년 전 | 1224 | |
| 2152 |
letsgolee
|
17년 전 | 2455 | |
| 2151 | 17년 전 | 1171 | ||
| 2150 |
아름다운세상
|
17년 전 | 1130 | |
| 2149 |
아름다운세상
|
17년 전 | 1378 | |
| 2148 |
아름다운세상
|
17년 전 | 2739 | |
| 2147 |
|
17년 전 | 2399 | |
| 2146 | 17년 전 | 2486 | ||
| 2145 | 17년 전 | 1188 | ||
| 2144 | 17년 전 | 1305 | ||
| 2143 | 17년 전 | 3251 | ||
| 2142 | 17년 전 | 2838 | ||
| 2141 | 17년 전 | 4110 | ||
| 2140 | 17년 전 | 2260 | ||
| 2139 | 17년 전 | 2349 | ||
| 2138 | 17년 전 | 1402 | ||
| 2137 | 17년 전 | 2517 | ||
| 2136 | 17년 전 | 2201 | ||
| 2135 | 17년 전 | 2961 | ||
| 2134 |
아름다운세상
|
17년 전 | 2471 | |
| 2133 |
Juinjang
|
17년 전 | 1634 | |
| 2132 | 17년 전 | 2432 | ||
| 2131 | 17년 전 | 1590 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기