Learn Before
Code

Draw a Gray Cross Over an Image (Pillow)

The following code opens an image named "hopper" and creates a Draw object using it to then draw two lines. First, a line from the top left (0,0) to the bottom right. Then, a line from the top right to the bottom left.

import sys from PIL import Image, ImageDraw with Image.open("hopper.jpg") as im: draw = ImageDraw.Draw(im) draw.line((0, 0) + im.size, fill=128) draw.line((0, im.size[1], im.size[0], 0), fill=128) # write to stdout im.save(sys.stdout, "PNG")

0

1

Updated 2021-08-21

Contributors are:

Who are from:

Tags

Python Programming Language

Data Science