title: Why is my JPG image quality (colors) darker after saving compared to original file?
body: <p>I load a JPG image into a System.Drawing.Image object, then I resize, then save. After saving, I noticed the color quality is much darker than the original. How do I retain the original, brighter,  color quality?</p>
  
  <p>Using VS2010 (VB.Net), and I have tried using EncoderParameters as follows:</p>
  
  <pre><code>Encoder.Quality = 100L
  Encoder.ColorDepth = 24
  Encoder.Compression = CompressionNone
  </code></pre>
  
  <p>This is a "simplified" version of the code I wrote. All the most important parts are here.</p>
  
  <pre><code>'***************************************
  ' Constants
  '***************************************
  Const DECREASE_RATIO As Double = 10.0
  
  '***************************************
  ' Initialize Variables
  '***************************************
  Dim dblRatio As Double = (100 - DECREASE_RATIO) * 0.01
  Dim objGraphics As System.Drawing.Graphics
  Dim imgJPEG_Current As System.Drawing.Image = Nothing
  Dim imgJPEG_New As System.Drawing.Bitmap = Nothing
  Dim objJPGCodec As Imaging.ImageCodecInfo = Nothing
  Dim arrEncoderParameters = New Imaging.EncoderParameters(3)
  
  '***************************************
  ' Default Values
  '***************************************
  With arrEncoderParameters
      .Param(0) = New Imaging.EncoderParameter(Imaging.Encoder.Quality, 100L)
      .Param(1) = New Imaging.EncoderParameter(Imaging.Encoder.ColorDepth, 24)
      .Param(2) = New Imaging.EncoderParameter(Imaging.Encoder.Compression, Imaging.EncoderValue.CompressionNone)
  End With
  
  '***************************************
  ' Get JPEG Codec
  '***************************************
  For Each objCodec As Imaging.ImageCodecInfo In Imaging.ImageCodecInfo.GetImageDecoders()
      If (objCodec.FormatID = Imaging.ImageFormat.Jpeg.Guid) Then
          objJPGCodec = objCodec
          Exit For
      End If
  Next
  
  '***************************************
  ' Load Current Image To Process
  '***************************************
  imgJPEG_Current = Image.FromFile(strFilePhysicalPath_Original, False)
  
  '***************************************
  ' Create Clone Of Current Image Resized Using New Size Ratio
  '***************************************
  imgJPEG_New = New Bitmap(CInt(imgJPEG_Current.Width * dblRatio), CInt(imgJPEG_Current.Height * dblRatio), imgJPEG_Current.PixelFormat)
  objGraphics = Graphics.FromImage(imgJPEG_New)
  With objGraphics
      .SmoothingMode = Drawing2D.SmoothingMode.HighQuality
      .InterpolationMode = Drawing2D.InterpolationMode.High
      .PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
      .CompositingQuality = Drawing2D.CompositingQuality.HighQuality
      .DrawImage(imgJPEG_Current, 0, 0, imgJPEG_New.Width, imgJPEG_New.Height)
      .Dispose()
  End With
  
  '***************************************
  ' Save New JPG File To Disk
  '***************************************
  imgJPEG_New.Save(strFilePhysicalPath_Delta, objJPGCodec, arrEncoderParameters)
  </code></pre>
  
  <p>I expected a smaller JPG file in dimensions but retaining the same color quality as the original. Instead, I get a smaller JPG file with darker colors that appear less vibrant.</p>