title: Reduce Color Count in PNG-8 Palette using FreeImage Library (C#)
body: <p>I was using the FreeImageNET libary to Quantize my Bitmap as</p>
  
  <pre><code>using (FreeImageAPI.FreeImageBitmap fiBitmap = FreeImageAPI.FreeImageBitmap.FromHbitmap(bmp.GetHbitmap()))
              {
                  if (fiBitmap.ColorDepth &gt; 24)
                  {
                      fiBitmap.ConvertColorDepth(FreeImageAPI.FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP);
                  }
  
                  //quantize using the NeuQuant neural-net quantization algorithm 
                  fiBitmap.Quantize(FreeImageAPI.FREE_IMAGE_QUANTIZE.FIQ_NNQUANT, 256);
  
  
                  fiBitmap.Save("test_z.png", FreeImageAPI.FREE_IMAGE_FORMAT.FIF_PNG, FreeImageAPI.FREE_IMAGE_SAVE_FLAGS.PNG_Z_BEST_COMPRESSION);
  
                  //fiBitmap.Save(ms, FreeImageAPI.FREE_IMAGE_FORMAT.FIF_PNG, FreeImageAPI.FREE_IMAGE_SAVE_FLAGS.PNG_Z_DEFAULT_COMPRESSION);
              }
  </code></pre>
  
  <p>This gives me a PNG-8, with a palette of 256 colors.
  Using Photoshop I found, I could further reduce the size if I used Adaptive Algorithm with reduced color palette say 128, 64, 16 etc. Reopening it again shows Photoshop fills in grey levels in those remaining(higher) indexes.</p>
  
  <p>I cannot get <code>FreeImageAPI.FreeImageBitmap.Quantize()</code> to churn out a similar PNG, with limited palette, <em>a la</em> PIL <code>convert()</code> where you can specify both the algorithm and the palette size.</p>
  
  <p>Thanks.</p>