[cairo] pycairo - reduce image size produced by surface.write_to_png()

Roger Holness hlnrog001 at gmail.com
Tue Aug 14 02:18:13 PDT 2007


I am working on a project that renders SVGs to png for use on cell
phones using cairo and librsvg

Can any of you suggest a way of reducing the size of the png produced
by write_to_png()? Obviously I understand that there will be a loss in

I tried setting the dpi used by rsvg (see below) but that shouldn't
and doesn't work - I need to be changing the dpi on my surface (I

I could reduce the dimensions of the surface, but there should be a
better way (I identify the screen size of the cell phone, and ideally
want to produce an image of that size, but lower quality than I am

Any help would be appreciated

<----code begin ---->

	surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,width,height) #width
and height of the image being rendered

        ctx = cairo.Context(surface)
        rsvg.set_default_dpi(dpi)	#played with various dpi's but has
no effect on the image produced
        svg = rsvg.Handle(None, outString) #outString is the svg (as a string)

        surface.write_to_png (fo) #writes to file object
<----code end---->


Roger Holness

More information about the cairo mailing list