|
 |
13³â Àü |
// ½æ³×ÀÏÈ ¸¸µé±â °¡·Î 370 Â¥¸® ¸ÞÀÎ À̹ÌÁö ¸¸µé±â
$dst_img = thumbnail ($$temp_cf,"370","");
make_imagefile ($dst_img,"$file_dir/1_$file_base","100");
################################################################################
// À̹ÌÁö·Îµå
################################################################################
function LoadImage ($fName) {
$file_ext = strtolower(substr(strrchr($fName,"."), 1));
switch ($file_ext) {
case "jpg": case "jpeg":
$img = @ImageCreateFromJPEG ($fName);
break;
case "gif":
$img = @ImageCreateFromGIF ($fName);
break;
case "png":
$img = @ImageCreateFromPNG ($fName);
break;
}
if (!$img) {
$img = ImageCreate (150, 30);
$bgc = ImageColorAllocate ($img, 255, 255, 255);
$tc = ImageColorAllocate ($img, 0, 0, 0);
ImageFilledRectangle ($img, 0, 0, 150, 30, $bgc);
ImageString ($img, 1, 5, 5, "Error loading $fName", $tc);
}
return $img;
}
################################################################################
// À̹ÌÁö ½æ³×ÀÏ ¸¸µé±â
################################################################################
function thumbnail ($filepath,$width="",$height="") {
$size=getimagesize($filepath); //¿øº» À̹ÌÁö»çÀÌÁ ±¸ÇÔ
if(!$height) {
$height=($size[1]*$width)/$size[0];
if($size[0] < $width) {
$width = $size[0];
$height = $size[1];
}
}
if(!$width) {
$width=($size[0]*$height)/$size[1];
if($size[1] < $height) {
$width = $size[0];
$height = $size[1];
}
}
$shr_rateX = $width / $size[0];
$shr_rateY = $height / $size[1];
$base = ($shr_rateX <= $shr_rateY) ? "y" : "x";
$src_im=LoadImage($filepath);
if($base == "y") {
$new_width=round(($size[0] * $height)/$size[1]); // (°¡·ÎÅ©±â * »õ·Î¿î ¼¼·Î Å©±â) / ¼¼·ÎÅ©±â
$offsetX = round(($new_width - $width) / 2); //°¢°¢ Á¿ì·Î Àß¶ó³¾ ±æÀÌ
$offsetY = 0;
}
if($base == "x") {
$size=getimagesize($filepath); //¿øº» À̹ÌÁö »çÀÌÁî ±¸ÇÔ
$new_height=round(($size[1] * $width)/$size[0]); // (¼¼·ÎÅ©±â * »õ·Î¿î °¡·ÎÅ©±â) / °¡·ÎÅ©±â
$offsetX = 0;
$offsetY = round(($new_height - $height) / 2); // °¢°¢ »óÇÏ·Î Àß¶ó³¾ ±æÀÌ
}
//$dst_img=ImageCreate($width,$height); //°á°ú¹° À̹ÌÁö »ý¼º
$dst_img=ImageCreateTrueColor($width,$height); //°á°ú¹° À̹ÌÁö »ý¼º
imagecopyresampled($dst_img,$src_im,0,0,$offsetX,$offsetY,$width,$height,ImageSX($src_im)-$offsetX,ImageSY($src_im)-$offsetY); //¸¸µé±â
//ImageCopyResized($dst_img,$src_im,0,0,$offsetX,$offsetY,$width,$height,ImageSX($src_im)-$offsetX,ImageSY($src_im)-$offsetY); //¸¸µé±â
return $dst_img;
}
################################################################################
// À̹ÌÁö»ý¼º
################################################################################
function make_imagefile ($dst_img,$filename,$quality="100") {
$file_ext = strtolower(substr(strrchr($filename,"."), 1));
//if(eregi("bmp", $file_ext)) {
// error_msg("Áö¿øÇÏÁö ¾Ê´Â ÆÄÀÏÇü½ÄÀÔ´Ï´Ù. ´Ù½Ã ½ÃµµÇØ ÁֽʽÿÀ.\\n\\n$file_ext ÆÄÀÏ Çü½Ä Àº Áö¿ø ÇÏÁö ¾Ê½À´Ï´Ù.");
// exit;
//}
if($file_ext == "jpg") ImageJPEG($dst_img, $filename, $quality);
elseif($file_ext == "gif") ImageGIF($dst_img, $filename);
elseif($file_ext == "png") ImagePNG($dst_img, $filename);
ImageDestroy($dst_img);
return 1;
} |
|
̵̧ : 779 |
̵̧
¸ñ·Ï
|
|