Python pillow code example

Example 1: pillow python

pip install pillow

Example 2: python image library

from PIL import image

img = image.open('C:\Users\you\path\to\your\image.jpg')
pix = img.getpixel((100,100))
img.putpixel((0,0),(0,0,255))

Example 3: python pil

from PIL import Image

img = Image.open("./my_image.png")

Example 4: 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")