/*******************************
        *方法    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);
}
}