title: System.Drawing.Image Save() producing inconsistent file sizes
body: <p>While converting TIFFs to PDFs, I noticed some of the PDFs were corrupted.  After some research, it appears the problem is in the System.Drawing.Image class.  To test this, instead of converting to PDFs, I had the program just read in the image files and re-save them.  Some of the newly saved files have inconsistent file sizes between different runs of the program.  The basic steps are:</p>
  
  <ol>
  <li>I read a TIFF image into a byte array.  </li>
  <li>I use the System.Drawing.Image.FromStream() method to create an image object from the byte array.  </li>
  <li>I then call the System.Drawing.Image.Save(stream) method to save the image to a new stream.</li>
  <li>I then examine the length of the stream.ToArray() method.</li>
  </ol>
  
  <p>The same input file results in a different output length between successive program executions.  The output length varies by a couple hundred bytes.  In addition, the resulting output length is more than twice the size of the input length, but I assume this is due to compression, or lack thereof.  I am running this on windows 7 32-bit with .net 4.</p>
  
  <p>Why might the output length vary like this?</p>
  
  <p>UPDATE:</p>
  
  <p>After reviewing this connect issue (<a href="https://connect.microsoft.com/VisualStudio/feedback/details/584681/system-drawing-image-flags-has-different-value-in-vista-and-windows-7" rel="nofollow">https://connect.microsoft.com/VisualStudio/feedback/details/584681/system-drawing-image-flags-has-different-value-in-vista-and-windows-7</a>) and the community comment on this MSDN page (<a href="http://msdn.microsoft.com/en-us/library/system.drawing.image.save.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.drawing.image.save.aspx</a>), it appears the issue is related to an operating system level bug in Windows 7.  Can anyone confirm this or offer a workaround?</p>