@@ -0,0 +1,1010 @@
+import picamera%0Afrom PIL import Image%0Afrom time import sleep%0A%0Awith picamera.PiCamera() as camera:%0A    camera.resolution = (640, 480)%0A    camera.framerate = 24%0A    camera.start_preview()%0A%0A    # Load the arbitrarily sized image%0A    img = Image.open('images/v1.png')%0A    # Create an image padded to the required size with%0A    # mode 'RGB'%0A    pad = Image.new('RGB', (%0A        (img.size%5B0%5D + 31 // 32) * 32,%0A        (img.size%5B1%5D + 15 // 16) * 16,%0A        ))%0A    # Paste the original image into the padded one%0A    pad.paste(img, (0, 0))%0A%0A    # Add the overlay with the padded image as the source,%0A    # but the original image's dimensions%0A    o = camera.add_overlay(pad.tostring(), size=img.size)%0A    # By default, the overlay is in layer 0, beneath the%0A    # preview (which defaults to layer 2). Here we make%0A    # the new overlay semi-transparent, then move it above%0A    # the preview%0A    o.alpha = 128%0A    o.layer = 3%0A%0A    # Wait indefinitely until the user terminates the script%0A    while True:%0A        sleep(1)

Test script for overlays