Quantizing image

Robin Dunn wrote:

Should be doable, although I probably won't be able to allow the 8-bit
data to be returned like the C++ version does without extra overhead
that probably wouldn't be worth it.

I actually don't care about the 8 bit data, only the target wxImage.
I expect my resulting code to look something like:

src=wx.Image("input.jpg", wx.BITMAP_TYPE_ANY)
dst=wx.EmptyImage(src.GetWidth(), src.GetHeight())
wx.Quantize.Quantize(src, dst, None, 325)
dst.SaveFile("output.png", wx.BITMAP_TYPE_PNG)

The 325 will be replaced with various numbers. I'd also
want to save to an wx.OutputStream that goes to memory
but it doesn't look like that is wrapped yet.

BTW, from a quick glance at the code it appears that wxQuantize can
only reduce to <= 256 colors, so you may still need to use something
else if you want to allow larger color sets that may still fit in
your size limits.

That certainly throws a spanner in the works. The backup plan
was to ship a copy of ppmquant for all platforms, and use
temporary files running with that.

Roger

Roger Binns wrote:

BTW, from a quick glance at the code it appears that wxQuantize can
only reduce to <= 256 colors, so you may still need to use something
else if you want to allow larger color sets that may still fit in
your size limits.
   
That certainly throws a spanner in the works. The backup plan
was to ship a copy of ppmquant for all platforms, and use temporary files running with that.

Roger,

I just looked up what is ppmquant on the link below,

http://netpbm.sourceforge.net/doc/ppmquant.html

and it says that ppmquant is obsolete -- might want to use pnmquant.

Bob