Jesper Larsen <jesper.webm...@gmail.com> writes:

> Unfortunately the files are quite big (up to ~300 kb). I have however
> tried using the Linux tool pngnq to reduce the file size with a factor
> ~3-4 with almost no degradation of the result.

>   Pixel depth (Pixel Depth): 32
>   Colour Type (Photometric Interpretation): RGB with alpha channel

>   Pixel depth (Pixel Depth): 8
>   Colour Type (Photometric Interpretation): PALETTED COLOUR (256
> colours, 0 transparent)

This means pngnq has quantized the original RGBA image with 8 bits per
channel to an image with a 256-color palette. I don't think Agg has any
support for rendering directly to a paletted image, so to achieve
similar results, you would have to do the quantization in a separate
pass anyway.

> I am not using transparency for anything. For a web application a
> reduction from 300 kb to 90 kb is really important so I hope you have
> some good ideas.

A web application needs to be fast, right? According to its home page,
pngnq "is limited mostly to off-line uses rather than real time image
delivery". You could take a look at PIL to see if it has any fast
quantization algorithms, and pass your result to it as in the
to_numeric.py example (see also webapp_demo.py for how to avoid using
the pylab machinery for figure management). If not, you could always
implement some fast quantization algorithm in numpy:

http://en.wikipedia.org/wiki/Color_quantization

My guess is that if you always produce similar-looking images, you could
fix the palette off-line using whatever fancy algorithm you like, and
then the actual conversion could be done pretty fast, especially if you
can forgo dithering - perhaps for many types of charts it is not
necessary.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to