Results 1 to 2 of 2
  1. #1
    manik's Avatar
    manik is online now Om Shanti!
    Join Date
    Apr 2008
    Location
    Boston, USA
    Posts
    13,172
    Thanks
    744
    Thanked 699 Times in 550 Posts
    Blog Entries
    4
    Feedback Score
    4 (100%)

    Default Jpeg Image File Size Gets Too Big on Resize - Asp .Net

    Jpeg Image File Size Gets Too Big on Resize - Asp .Net

    If you save a Bitmap in a jpeg format with 100% quality, your saved jpeg file size might be lot bigger then your original file size.

    To avoid this you have to specify the quality param for jpeg files.

    Here is some example codes in C#, considering you are saving to jpeg from a Bitmap.

    Code:
    System.Drawing.Imaging.ImageCodecInfo ici = GetImageCodec("image/jpeg");
    System.Drawing.Imaging.EncoderParameters eps = new System.Drawing.Imaging.EncoderParameters(1);
    eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 75L);
    bmp.Save(imageFolderAbsolutePath + "/" + saveAsName, ici, eps);
    
    public ImageCodecInfo GetImageCodec(string mimetype)
    {
    mimetype = mimetype.ToLower();
    foreach (ImageCodecInfo ici in ImageCodecInfo.GetImageEncoders())
    {
        if (ici.MimeType.ToLower() == mimetype)
        return ici;
    }
    return null;
    }
    Free Classified Ads & BUSINESS/PROFESSIONAL SOCIAL NETWORK


  2. #2
    ecarmover is offline Senior
    Join Date
    Jul 2011
    Posts
    534
    Thanks
    0
    Thanked 1 Time in 1 Post
    Feedback Score
    0

Similar Threads

  1. Replies: 18
    Last Post: 03-03-2012, 11:39 PM
  2. FFmpeg converting to flv but with 0 file size
    By HemZone in forum Website & Server Administration
    Replies: 0
    Last Post: 01-05-2012, 06:35 AM
  3. Replies: 3
    Last Post: 12-17-2010, 05:48 AM
  4. Replies: 1
    Last Post: 02-02-2010, 11:35 AM
  5. Replies: 7
    Last Post: 08-28-2009, 02:43 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •