/*******************************
*方法 public
*功能 改变图片的宽、高
*参数
*返回 无
********************************/
function ResizeImage($im,$maxwidth,$maxheight = '',$name){
$width = @imagesx($im);
$height = @imagesy($im);
if($maxwidth && $width > $maxwidth){
$RESIZEWIDTH = false;
if($maxwidth && $width > $maxwidth){
$widthratio = $maxwidth/$width;
$RESIZEWIDTH = true;
}
if($RESIZEWIDTH){
$ratio = $widthratio;
} $newwidth = $width * $ratio;
$newheight = $height * $ratio;
if(function_exists("imagecopyresampled")){
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}else{
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
imagejpeg ($newim,$name);
imagedestroy ($newim);
}else{
imagejpeg ($im,$name);
}
}
*方法 public
*功能 改变图片的宽、高
*参数
*返回 无
********************************/
function ResizeImage($im,$maxwidth,$maxheight = '',$name){
$width = @imagesx($im);
$height = @imagesy($im);
if($maxwidth && $width > $maxwidth){
$RESIZEWIDTH = false;
if($maxwidth && $width > $maxwidth){
$widthratio = $maxwidth/$width;
$RESIZEWIDTH = true;
}
if($RESIZEWIDTH){
$ratio = $widthratio;
} $newwidth = $width * $ratio;
$newheight = $height * $ratio;
if(function_exists("imagecopyresampled")){
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}else{
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
imagejpeg ($newim,$name);
imagedestroy ($newim);
}else{
imagejpeg ($im,$name);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货