#!/usr/bin/env python3 """ Simple test script for Pillow library. Creates a 10x10 image with yellow background and green square in the middle. """ from PIL import Image, ImageDraw print("Creating 10x10 image...") img = Image.new('RGB', (10, 10), color='yellow') draw = ImageDraw.Draw(img) draw.rectangle([(3, 3), (6, 6)], fill='green') img.save('foo.png') print("Image saved as foo.png") print("\nLoading and verifying image...") loaded_img = Image.open('foo.png') assert loaded_img.format == 'PNG', f"Expected PNG format, got {loaded_img.format}" print(f"✓ Format is PNG") assert loaded_img.size == (10, 10), f"Expected size (10, 10), got {loaded_img.size}" print(f"✓ Size is 10x10") pixel_yellow = loaded_img.getpixel((2, 2)) assert pixel_yellow == (255, 255, 0), f"Expected yellow (255, 255, 0) at (2, 2), got {pixel_yellow}" print(f"✓ Yellow color found at (2, 2): {pixel_yellow}") pixel_green = loaded_img.getpixel((5, 5)) assert pixel_green == (0, 128, 0), f"Expected green (0, 128, 0) at (5, 5), got {pixel_green}" print(f"✓ Green color found at (5, 5): {pixel_green}") print("\n✓ All tests passed!")