title: What influences the C# PNG lossless compression ratio?
body: <pre><code>Bitmap clip = new Bitmap((int)(8.5 * 72), (int)(11 * 72));
  MemoryStream stream = new MemoryStream();
  clip.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
  byte[] bytes = stream.ToArray();
  </code></pre>
  
  <p>I ran it on my machine and the <code>bytes.Length</code> was <code>8587</code>, on my fellow developers' machines it was <code>2009</code>. Supposedly in <code>.NET</code> there's no way to influence the quality (or rather the ratio in this case) of the PNG compression. This particular image is a blank one, and I have other tests which work with images with content and they confirm that the compression is lossless (I encountered some debates where that was a question).</p>
  
  <p>But even if the compression is lossless, there's is a tradeoff between the compression algorithm runtime + CPU utilization vs the compression ratio / quality. I wonder how <code>System.Drawing.Imaging</code> determines the quality, because this above case clearly shows that there can be differences. How can I be sure that on the client's machine it won't choose 100% quality (which would yield a 1.457.337 size file)?</p>
  
  <p>Related material:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/6922533/png-compression-in-net">PNG Compression in .net</a></li>
  <li><a href="https://stackoverflow.com/questions/2419222/c-sharp-how-to-change-png-quality-or-color-depth">C# - How to change PNG quality or color depth</a></li>
  <li><a href="https://stackoverflow.com/questions/2420948/save-png-image-with-custom-quality-or-color-depth-in-c-sharp">save png image with custom quality or color depth in C#</a></li>
  <li><a href="http://bytes.com/topic/c-sharp/answers/700494-how-specify-compression-level-when-saving-loseless-pngs" rel="nofollow noreferrer">http://bytes.com/topic/c-sharp/answers/700494-how-specify-compression-level-when-saving-loseless-pngs</a></li>
  </ul>
  
  <p>Additional info:</p>
  
  <ul>
  <li>Checked out another developer's machine and it's consistent with my other colleagues results, so my machine is the outlier.</li>
  <li>Each machine has Win 7 Prof 64 bit installed on it, the particular tests are NUnit and we are using .NET 4</li>
  <li>Can any of my installed software override the behavior of .NET in this respect. For example I have IrfanView installed, can it replace any system wide "filters" or dlls used? (BTW I checked in the Modules debug view and I don't see any unusual dll loaded)</li>
  <li>Can it influenced by some windows OS desktop quality settings or something?</li>
  </ul>