How to reduce the file size of the image but keeping the quality in C# .net?

This question already has an answer here:

  • Resizing an Image without losing any quality [closed]

    11 answers

Just wandering, how to reduce the file size of the image but keeping the quality in C# .net?

I have the following code use to save the image taken from ipad:

Bitmap srcBmp = new Bitmap(file.InputStream);

int w = srcBmp.Width;
int h = srcBmp.Height;
if (srcBmp.Width > 2732 && srcBmp.Height > 2048)
    w = 2732;
    h = 2048;

SizeF newSize = new SizeF(w, h);
Bitmap target = new Bitmap(w, h);
var destRect = new Rectangle(0, 0, w, h);

HttpContext.Response.ContentType = "image/jpeg";
using (var graphics = Graphics.FromImage(target))
    graphics.CompositingMode = CompositingMode.SourceCopy;
    graphics.CompositingQuality = CompositingQuality.HighQuality;
    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
    graphics.SmoothingMode = SmoothingMode.HighQuality;
    graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

    using (var wrapMode = new ImageAttributes())
        graphics.DrawImage(srcBmp, destRect, 0, 0, w, h, GraphicsUnit.Pixel, wrapMode);
        using (FileStream fileStream = new FileStream(fname, FileMode.Create))
            target.Save(fileStream, System.Drawing.Imaging.ImageFormat.Jpeg);

The Image been saved is always over 14MB. Anyway I can keep the image quality and reduce the file size below 2MB?

I don’t think that much reduction without decresing the picture quality is possible. However you can remove the metadata from an image using the Exif library without reducing the picture quality

Or if you are good with reduction in picture quality you can use GID