from PIL import Image, ImageSequence import numpy as np
defdraw(im, origin, offsetCoords, value): for c in offsetCoords: im.putpixel(origin, value) dx = (c[0] - 100) // 2 dy = (c[1] - 100) // 2 origin[0] += dx origin[1] += dy
im = Image.open('white.gif') coords = [] for i in ImageSequence.Iterator(im): idata = list(i.getdata()) idx = idata.index(8) x = idx % 200 y = idx // 200 coords.append((x, y))