Forgive me if this is a real newbie question, but hey, as far as PIL goes, I'm a newbie. I'm trying to write a script that draws on an image, then splits the image into two copies and draws more on them independently. I can't seem to figure out how to do that second part. I've written up a sample script to demonstrate the issue. If working correctly, the output file snippet11a.png should contain a triangle, snippet11b.jpg should contain the triangle with a rectangle superimposed, and snippet11c.jpg should contain the triangle with a circle superimposed (but not the rectangle).
Can anyone suggest a path? If it helps, I'm running python 2.6.1 on Windows Vista (not my preferred environment). import Image, aggdraw size = 400, 300 cwhite = 255, 255, 255 # 23-Aug-2009 # This little program is an experiment in what it takes to make separate # images, which can be drawn on separately from each other. I have been # having a problem that drawing on any copy of an image ends up drawing on # the original image. The only way I found that creates a truly independent # image is to start from a separate Image.new() call. Im2 = Image.new("RGBA", size, cwhite) Im3 = Image.new("RGBA", size, cwhite) draw2 = aggdraw.Draw(Im2) color1 = (0,0,127) opacity1 = 127 brush1 = aggdraw.Brush(color1, opacity=opacity1) draw2.polygon((100, 100, 300, 100, 200, 200), aggdraw.Pen("black"), brush1) draw2.flush() Im2.save("C:\Temp\snippet11a.png") # Im3 = Im2.copy # This command causes a "AttributeError: 'function' object # has no attribute 'mode'" error at the next draw on Im3 draw2a = draw2 # Drawing on a copy of the draw object will draw on the same image draw2a.rectangle((50, 50, 250, 250), aggdraw.Pen("black"), brush1) draw2a.flush() Im2.save("C:\Temp\snippet11b.png") draw3 = aggdraw.Draw(Im3) draw3.ellipse((150, 50, 350, 250), aggdraw.Pen("black"), brush1) draw3.flush() Im3.save("C:\Temp\snippet11c.png")
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig