Batch

Three city color chips.

Three city color chips in a loop. Print names and sizes.

Goal

Save nairobi.png, mombasa.png, kisumu.png.

from PIL import Image
colors = {'nairobi': (0, 128, 64), 'mombasa': (29, 79, 122), 'kisumu': (200, 40, 40)}
for name, color in colors.items():
    im = Image.new('RGB', (48, 32), color)
    im.save(name + '.png')
    print(name, im.size, color)
from pathlib import Path
print(sorted(p.name for p in Path('.').glob('*.png'))[:6])
from PIL import Image
print(Image.open('nairobi.png').getpixel((0, 0)))
from PIL import Image
print(Image.new('RGB', (2, 2), (255, 200, 0)).size)