title: ImageMagick: Lossless max compression for PNG?
body: <p>I'd like to achieve a maximum amount of compression when saving to a lossless PNG using ImageMagick. I'm doing batch conversion of many PSDs.</p>
  
  <p>I tried a few things, but it looks to me like the resulting PNG image is not as sharp as original image, although my wife cannot see it.</p>
  
  <p>These are current arguments I'm playing with:</p>
  
  <pre><code>convert -depth 24 -define png:compression-filter=1 \ 
    -define png:compression-level=9 -define png:compression-strategy=2 
  </code></pre>
  
  <p>According to:
  <a href="http://www.imagemagick.org/script/command-line-options.php#define" rel="noreferrer">http://www.imagemagick.org/script/command-line-options.php#define</a></p>
  
  <p>And <a href="http://www.w3.org/TR/PNG-Filters.html" rel="noreferrer">http://www.w3.org/TR/PNG-Filters.html</a></p>
  
  <p>That means:</p>
  
  <ul>
  <li>compression filter is  1 (Sub)</li>
  <li>max compression level 9</li>
  <li>compression strategy is 2 huffman_only (so no filtering, although this compression filter shall be lossless)</li>
  </ul>
  
  <p>According to the documentation: <em>"valid values are 0 through 4, meaning default, filtered, huffman_only, rle, and fixed ZLIB compression strategy. If you are using an old zlib that does not support Z_RLE (before 1.2.0) or Z_FIXED (before 1.2.2.2), values 3 and 4, respectively, will use the zlib default strategy instead."</em></p>
  
  <p>BTW, My images are 960x720 pixels.</p>
  
  <p>(If I use default compression strategy 0, I get large files. It might be that compression-filter of 9 and compression-strategy of 0 are producing smaller size images, but I am still not sure if it is lossless or not).</p>
  
  <p>Questions:</p>
  
  <ol>
  <li>Is this lossless compression? If not, where is the mistake?</li>
  <li>Any idea how to achieve better lossless compression?</li>
  </ol>