用System.Drawing.Image生成缩略图,一个70Kb的800*600jpg图片生成后是130*130jpg的容量还有45这么大,我生成缩略图就是想让容量下加载快些,结果小这么点,我觉得这么小的jpg图片应该在10Kb左右差不多了……怎么缩小缩略图的容量呢?

解决方案 »

  1.   

    放 div里,控制div的高度宽度
      

  2.   

    等比例缩放图片
    <script language="JavaScript">
    var flag=false;
    function DrawImage(ImgD,iwidth,iheight){
      var image=new Image();
      image.src=ImgD.src;
      if(image.width>0 && image.height>0){
      flag=true;
      if(image.width/image.height>= iwidth/iheight){
      if(image.width>iwidth){   
      ImgD.width=iwidth;
      ImgD.height=(image.height*iwidth)/image.width;
      }else{
      ImgD.width=image.width;   
      ImgD.height=image.height;
      }
      ImgD.alt=image.width+"×"+image.height;
      }
      else{
      if(image.height>iheight){   
      ImgD.height=iheight;
      ImgD.width=(image.width*iheight)/image.height;   
      }else{
      ImgD.width=image.width;   
      ImgD.height=image.height;
      }
      ImgD.alt=image.width+"×"+image.height;
      }  }
    }  
    http://topic.csdn.net/u/20100525/15/7b9f9fe3-e862-48b5-86e2-3b72a9525690.html
      

  3.   

    /// <summary>   
    /// 修改指定图片的分辨率   
    /// </summary>   
    /// <param name="fileFoldUrl">文件夹url</param>   
    /// <param name="fileName">文件名</param>   
    /// <param name="filePath">文件路径,带文件名</param>   
    /// <param name="_width">分辨率的宽</param>   
    /// <param name="_height">分辨率的高</param>   
    public void update_picture(string fileFoldUrl, string fileName, string filePath, int _width, int _height)   
    {   
        byte[] zp = this.load_pictMemory(filePath);   
      
        MemoryStream ms = new MemoryStream(zp);   
      
        System.Drawing.Image img = System.Drawing.Image.FromStream(ms);   
      
        Bitmap btp = new Bitmap(img, _width, _height);   
      
        DirectoryInfo dti = new DirectoryInfo(fileFoldUrl);   
      
        FileInfo[] fis = dti.GetFiles();   
      
        string fileUrl = fileFoldUrl + fileName;   
      
        btp.Save(fileUrl);   
    }  
      

  4.   

    本来我是直接放img里控制宽高,但这样不好,图片容量大了加载慢,别人要是网速慢点都很慢才显示出来,所以生成个缩略图,在首页显示,具体进去也能看大图!