File1.PostedFile.SaveAs(Server.MapPath(filename));  System.Drawing.Image image,aNewImage;
int width,height,newwidth,newheight;      
image=System.Drawing.Image.FromFile(Server.MapPath(filename));
System.Drawing.Image.GetThumbnailImageAbort callb =new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);    
width=image.Width;
height=image.Height;
newwidth=width/3;newheight=height/3; 
aNewImage=image.GetThumbnailImage(newwidth,newheight,callb,new System.IntPtr());
aNewImage.Save(Server.MapPath(oldpatch+"/small"+currentTime.ToString().Replace(" ","").Replace(":","")+"."+nam));
image.Dispose();
aNewImage.Dispose();
Response.Write("<script>alert(\"添加成功!\");</script>");

解决方案 »

  1.   

    更改保存图片的类型为GIF ,这样会小很多。
    aNewImage.Save(Server.MapPath.......,System.Drawing.Imaging.ImageFormat.Gif)
      

  2.   

    System.Drawing.Imaging.ImageFormat.Gif)
    图片质量太差了
    System.Drawing.Imaging.ImageFormat.Jpg
    图片体积又太大
    没有折中的方法吗?????????
      

  3.   

    wsImage生成的缩略图质量较好而且也不大
      

  4.   

    public void pic_zero(string sourcepath,string aimpath,int scale)
    {
    string originalFilename =sourcepath;
    //生成的高质量图片名称
    string strGoodFile =aimpath; //从文件取得图片对象
    System.Drawing.Image image = System.Drawing.Image.FromFile(originalFilename);
    int iImgWidth = image.Width;
    int iImgHeight = image.Height;
    int iScale = (iImgWidth / scale)>(iImgHeight/scale) ? (iImgWidth / scale) : (iImgHeight / scale); //取得图片大小
    System.Drawing.Size size = new Size(image.Width / iScale , image.Height / iScale);
    //新建一个bmp图片
    System.Drawing.Image bitmap = new System.Drawing.Bitmap(size.Width,size.Height);
    //新建一个画板
    System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
    //设置高质量插值法
    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
    //设置高质量,低速度呈现平滑程度
    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
    //清空一下画布
    g.Clear(Color.Blue);
    //在指定位置画图
    g.DrawImage(image, new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), 
    new System.Drawing.Rectangle(0, 0, image.Width,image.Height),
    System.Drawing.GraphicsUnit.Pixel);
    //保存高清晰度的缩略图
    bitmap.Save(strGoodFile, System.Drawing.Imaging.ImageFormat.Jpeg);
    g.Dispose();
    }