The best source of info for pycairo is the tutorial at <a href="http://www.tortall.net/mu/wiki/CairoTutorial">http://www.tortall.net/mu/wiki/CairoTutorial</a>;<br>and then of course the docs at <a href="http://www.cairographics.org/documentation/">http://www.cairographics.org/documentation/</a>; especialy the cookbook and samples. There is no really comprehensive guide on cairo at the moment.<br>
<br>Most of the more advanced question I had were solved by reading code from software that uses cairo eg: GTK and Mono Moonlight come to mind.<br><br>Have fun with cairo!<br><br>~Gerdus<br><br><div class="gmail_quote">On Sun, May 25, 2008 at 2:00 PM, Wolfgang Lipp <<a href="mailto:paragate@gmx.net">paragate@gmx.net</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
<br>
YAY, it WORKS! thanks so much, the first useful pointer in days. do you
happen to know a site where people post useful recipes concerning cairo
/ other graphics processing in pyhon (other than the obvious aspn
cookbook)? any comprehensive guide to caito / pycairo? <br>
<br>
you know i find it hard to figure out to do stuff like this in cairo.
as soon as i know, it's not so bad, i'll simply wrap it as `def
scale_image(...)` and presto. it's just those working code examples for
various tasks that i need. i've already hatched a few methods to draw
simple shapes, now i have raster scaling @ ffx3 quality. i am happy.<br>
<br>
cheers & ~flow<div><div></div><div class="Wj3C7c"><br>
<br>
Gerdus van Zyl wrote:
<blockquote type="cite">
<pre>To resample a png in pyCairo you need this:
import cairo
img = cairo.ImageSurface.create_from_png("in.png")
width = img.get_width()
height = img.get_height()
imgpat = cairo.SurfacePattern(img)
scaler = cairo.Matrix()
#1 = 100%; 2 = 50%;0.5 = 200%
scaler.scale(2,2) #50% downscale in this case
imgpat.set_matrix(scaler)
#set resampling filter
imgpat.set_filter(cairo.FILTER_BEST)
canvas = cairo.ImageSurface(cairo.FORMAT_ARGB32,320,240)
ctx = cairo.Context(canvas)
ctx.set_source(imgpat)
ctx.paint()
canvas.write_to_png("out.png")
>From reading your posts to other lists I believe PIL is simpler. But
it depends on your use case of course.
~Gerdus
On Sat, May 24, 2008 at 12:04 PM, Wolfgang Lipp <a href="mailto:paragate@gmx.net" target="_blank"><paragate@gmx.net></a> wrote:
</pre>
<blockquote type="cite">
<pre>[also posted to: comp.lang.python]
hi all,
i've heard cairo has become the image scling library for firefox3. is
that true? wonderful, i want to do that in python. there's a python
interface for cairo, right? i've used it before to do simple vector
stuff. seems to work. however, i haven't been able to find relevant
pointers via google. (rant: your mailman interface here is incredibly
unsuited to promote open discussions).
so do you have any pointers on how to resize a raster image with python
using cairo? i've been jumping through hoops for a while now, and i
believe it should be easier.
cheers and ~flow
ps. related (long) posts:
<a href="http://groups.google.com/group/pyglet-users/browse_frm/thread/44253ad01d809da5/cd051e6bced271e1#cd051e6bced271e1" target="_blank">http://groups.google.com/group/pyglet-users/browse_frm/thread/44253ad01d809da5/cd051e6bced271e1#cd051e6bced271e1</a>
<a href="http://groups.google.com/group/comp.lang.python/browse_frm/thread/5df65d99cff0d7bb#" target="_blank">http://groups.google.com/group/comp.lang.python/browse_frm/thread/5df65d99cff0d7bb#</a>
_______________________________________________
cairo mailing list
<a href="mailto:cairo@cairographics.org" target="_blank">cairo@cairographics.org</a>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a>
</pre>
</blockquote>
<pre> </pre>
</blockquote>
</div></div></div>
</blockquote></div><br>