|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /home/queenjbs/www/gallary/ |
Upload File : |
<?
$image = $vName;
//echo $image;
make_thumbnail("../files/board/$image", 100, 100, "../files/board/sontop/$image");
if($image) {
$img_size = GetImageSize("../files/board/".$image);
$x = $img_size[0];
$y = $img_size[1];
$re_imgX = 500;
$re_imgY = ($y * 500) / $x;
if($re_imgX < $x){
make_thumbnail("../files/board/$image", $re_imgX, $re_imgY, "../files/board/resize/$image");
}
}
function make_thumbnail($source_path, $width, $height, $thumbnail_path){
list($img_width,$img_height, $type) = getimagesize($source_path);
if ($type!=1 && $type!=2 && $type!=3 && $type!=15) return;
if ($type==1) $img_sour = imagecreatefromgif($source_path);
else if ($type==2 ) $img_sour = imagecreatefromjpeg($source_path);
else if ($type==3 ) $img_sour = imagecreatefrompng($source_path);
else if ($type==15) $img_sour = imagecreatefromwbmp($source_path);
if ($img_width > $img_height) {
$w = round($height*$img_width/$img_height);
$h = $height;
$x_last = round(($w-$width)/2);
$y_last = 0;
} else {
$w = $width;
$h = round($width*$img_height/$img_width);
$x_last = 0;
//$y_last = round(($h-$height)/2);
$y_last = 0;
}
if ($img_width < $width && $img_height < $height) {
$img_last = imagecreatetruecolor($width, $height);
$x_last = round(($width - $img_width)/2);
$y_last = round(($height - $img_height)/2);
imagecopy($img_last,$img_sour,$x_last,$y_last,0,0,$w,$h);
imagedestroy($img_sour);
$white = imagecolorallocate($img_last,255,255,255);
imagefill($img_last, 0, 0, $white);
} else {
$img_dest = imagecreatetruecolor($w,$h);
imagecopyresampled($img_dest, $img_sour,0,0,0,0,$w,$h,$img_width,$img_height);
$img_last = imagecreatetruecolor($width,$height);
imagecopy($img_last,$img_dest,0,0,$x_last,$y_last,$w,$h);
imagedestroy($img_dest);
}
if ($thumbnail_path) {
if ($type==1) imagegif($img_last, $thumbnail_path, 100);
else if ($type==2 ) imagejpeg($img_last, $thumbnail_path, 100);
else if ($type==3 ) imagepng($img_last, $thumbnail_path, 100);
else if ($type==15) imagebmp($img_last, $thumbnail_path, 100);
} else {
if ($type==1) imagegif($img_last);
else if ($type==2 ) imagejpeg($img_last);
else if ($type==3 ) imagepng($img_last);
else if ($type==15) imagebmp($img_last);
}
imagedestroy($img_last);
}
?>