[cairo] Reducing PNG Image Size

Mohit Sindhwani ml3p at onghu.com
Tue Sep 23 19:02:34 PDT 2008


Hi!  I'm using Cairo to generate PNG files that are created by joining 
smaller tiles together and drawing some more items on top of that.  Now, 
in some cases, this ends up producing files that are 3000 pixels by 2000 
pixels - which is large, but the resultant saved file is about 20MBytes.

Now, I read that PNG file sizes can be similar to GIF and I'm wondering 
how I could tweak my usage of Cairo to do this.  I think I've read 
through the API of surfaces, PNG surfaces, image surfaces and a couple 
of other things on the Cairo documentation site, but I fear that I 
haven't been able to find how to reduce/ control the size of the images 
produced.  Any idea how I should go about it?

I found that pngcrush can reduce the size and it claims to use libpng 
and zlib - both of which are also being used by Cairo, so I'm wondering 
if there's something inherent?

By the way, in the case of these images, transparency is not needed.

A nudge in the correct direction would be appreciated!

Thanks
Mohit.


More information about the cairo mailing list