raise proper exception
[PyX.git] / examples / bitmap / pil.py
bloba8c1edbef744e43798e91172a5319422d10fddde
1 from pyx import *
3 # support Image module either from PIL or pillow
4 try:
5 from PIL import Image
6 except ImportError:
7 import Image
9 im = Image.new("RGB", (3, 1))
10 im.putpixel((0, 0), (255, 0, 0))
11 im.putpixel((1, 0), (0, 255, 0))
12 im.putpixel((2, 0), (0, 0, 255))
14 c = canvas.canvas()
15 c.insert(bitmap.bitmap(0, 0, im, height=0.8))
16 c.writeEPSfile("pil")
17 c.writePDFfile("pil")