[PHP] - Thumbnail 함수
PHP 2011. 6. 28. 18:13[PHP] - Make ThumbNail
################ Thumb Nail ###################
function MakeThumb($file_path, $save_path, $width){
$imginfo = getimagesize($file_path);
//print_r($imginfo);
//$imginfo[2] = "2";
if($imginfo[2] != 1 && $imginfo[2] != 2 && $imginfo[2] != 3){
return "확장자가 jp(e)g/png/gif 가 아닙니다.";
}
if($imginfo[2] == 1) $getfile = imagecreatefromgif($file_path);
else if($imginfo[2] == 2) $getfile = imagecreatefromjpeg($file_path);
else if($imginfo[2] == 3) $getfile = imagecreatefrompng($file_path);
$height = ( $width / $imginfo[0] ) * $imginfo[1];
$make_img = imagecreatetruecolor($width, $height);
imagecopyresampled($make_img, $getfile, 0, 0, 0, 0, $width, $height, $imginfo[0], $imginfo[1]);
if($imginfo[2] == 1) imagegif($make_img, $save_path, 90); // 1~100
else if($imginfo[2] == 2) imagejpeg($make_img, $save_path, 90); // 1~100
else if($imginfo[2] == 3) imagepng($make_img, $save_path, 9); // 1~9
imagedestroy($make_img);
return true;
}
##### Call #####
MakeThumb($dir.$real_filename, $thumb."thumb_".$real_filename, $width);
경로 + 파일명//
'PHP' 카테고리의 다른 글
[PHP] - 한글 문자열 자르기( ex) 공지사항 오늘은... ) (0) | 2011.07.01 |
---|---|
[PHP] - PHP 프로그래밍중 한가지 팁!!! (2) | 2011.06.30 |
[PHP] - 유효성 날짜구하기 (0) | 2011.06.28 |
[PHP] - Sql 인젝션 공격 방어법 (0) | 2011.06.28 |
[PHP] - Str_replace 함수 사용법 (0) | 2011.06.28 |