|
| 1 | +import PIL.Image |
| 2 | +import PIL.ImageDraw |
| 3 | +import PIL.ImageOps |
| 4 | + |
| 5 | +im = PIL.Image.new('RGBA', (1024, 1024), (0, 0, 0, 0)) |
| 6 | +imDraw = PIL.ImageDraw.ImageDraw(im) |
| 7 | +# Draw first rectangle. |
| 8 | +imDraw.rectangle(((52, 277), (971, 746)), fill = (255, 233, 204, 255), outline = (0, 0, 0, 255), width = 20) |
| 9 | +# Draw lines for bottom of envelope. |
| 10 | +imDraw.line(((52, 746), (750, 277)), fill = (0, 0, 0, 255), width = 20) |
| 11 | + |
| 12 | +# Draw top of envelope. |
| 13 | +#imDraw.polygon(((52, 277), (511.5, 511.5), (971, 277)), fill = (255, 220, 173, 255), outline = (0, 0, 0, 255), width = 20) |
| 14 | +#imDraw.polygon(((30, 277), (511.5, 511.5), (993, 277)), fill = (255, 220, 173, 255), outline = (0, 0, 0, 255), width = 20) |
| 15 | +imDraw.polygon(((30, 277), (512, 512), (993, 277)), fill = (255, 220, 173, 255), outline = (0, 0, 0, 255), width = 20) |
| 16 | + |
| 17 | +# Cut the lines out of the edge. |
| 18 | +imDraw.rectangle(((12, 237), (1011, 786)), outline = (0, 0, 0, 0), width = 40) |
| 19 | + |
| 20 | + |
| 21 | +# Okay, so we are actually doing something dump to compensate for PIL issues. So |
| 22 | +# what we are doing is grabbing 1/2 of the image, mirroring it, then pasting it |
| 23 | +# back in. |
| 24 | +cop = PIL.ImageOps.mirror(im.copy().crop((0, 0, 512, 1024))) |
| 25 | +im.paste(cop, (512, 0)) |
| 26 | + |
| 27 | +im.save('envelope_1024.png') |
0 commit comments