Reputation: 31
Suppose I create a blank area in a window and draw some lines in it, how can I save that in a .png or .jpg? Or maybe convert it to an object PIL could understand?
Upvotes: 3
Views: 3878
Reputation: 659
Answer here: Using Pycairo to generate images dynamically and serve in Django though it only says how to save to .png.
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
context = cairo.Context(surface)
# Draw something ...
surface.write_to_png('filename')
Upvotes: 6