Pillow online course

Filters and drawing

Blur, sharpen, and put a caption on an image.

from PIL import Image, ImageDraw, ImageFilter, ImageFont

im = Image.open("input.jpg").convert("RGB")
im = im.filter(ImageFilter.SMOOTH)
draw = ImageDraw.Draw(im)
draw.text((24, 24), "lab photo", fill=(255, 255, 255))
im.save("captioned.jpg", quality=90)

Coordinates start at the top-left. If you need a guaranteed font, pass a .ttf path to ImageFont.truetype. Keep a copy of the original file; filter chains are easy to overdo.