<?
/* 썸네일 파일 생성 시작*/
function create_thumnail($url, $width=0, $height=0)
{
global $HTTP_SERVER_VARS;
if ($url[0] == "/") $fname = $url;
else $fname = $url;
$imsize = @getimagesize($fname);
if (empty($imsize)) return;
if ($imsize[0] >= 10 && $imsize[1] >= 10) {
if ($width > 0) {
if ($imsize[0] > $width) {
$imsize[1] = intval($imsize[1] * $width / $imsize[0]);
$imsize[0] = $width;
}
}
if ($height > 0) {
if ($imsize[1] > $height) {
$imsize[0] = intval($imsize[0] * $height / $imsize[1]);
$imsize[1] = $height;
}
}
}
//$src = gd_imagecreate($url);
$pos = strrpos($url, ".");
$ext = strtolower(substr($url, $pos + 1));
if ($ext == "jpeg" || $ext == "jpg") $src = imagecreatefromjpeg($url);
else if ($ext == "gif") $src = imagecreatefromgif($url);
else if ($ext == "bmp") $src = imagecreatefromwbmp($url);
else if ($ext == "png") $src = imagecreatefrompng($url);
$dest = imagecreatetruecolor($imsize[0], $imsize[1]);
// 이미지 정보
list($image_width, $image_height) = getimagesize($fname);
@imagecopyresampled($dest, $src, 0, 0, 0, 0, $imsize[0], $imsize[1], $image_width, $image_height);
imagejpeg($dest, $fname);
// echo "<img src='$fname' width='${imsize[0]}' height='${imsize[1]}' border='0'>";
}
/* 썸네일 파일 생성 끝*/
?>
사용시...
//create_thumnail(BBS_DATA_PATH."/".$folder_path."/".$realfile, 540, 0);
create_thumnail(BBS_THUMNAIL_PATH."/".$folder_path."/".$realfile, 138, 0);