python pillow open image code example

Example 1: PIL image example

>>> from PIL import Image
>>> im = Image.open("image.jpg")
>>> im.show()

Example 2: pil python image

from PIL import Image
im = Image.open("bride.jpg")
im.rotate(45).show()

Example 3: plot path in pillow python

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")