title: High quality JPEG compression with c#
body: <p>I am using C# and want to save images using JPEG format. However .NET reduces quality of the images and saves them with compression that is not enough.</p>
  
  <p>I want to save files with their original quality and size. I am using the following code but compression and quality are not like the original ones. </p>
  
  <pre><code>Bitmap bm = (Bitmap)Image.FromFile(FilePath); 
  ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); 
  ImageCodecInfo ici = null; 
  
  foreach (ImageCodecInfo codec in codecs)
  { 
      if (codec.MimeType == "image/jpeg") 
      ici = codec; 
  } 
  
  EncoderParameters ep = new EncoderParameters(); 
  ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)100); 
  bm.Save("C:\\quality" + x.ToString() + ".jpg", ici, ep);
  </code></pre>
  
  <p>I am archiving studio photos and quality and compression is very important. Thanks.</p>