out = Image.new('RGB', size)
for x in range(size[0]):
    for y in range(size[1]):
        histogram = defaultdict(int)
for x2 in range(x * multiplier, (x + 1) * multiplier):
    for y2 in range(y * multiplier, (y + 1) * multiplier):
        histogram[img.getpixel((x2, y2))] += 1
color = max(iter(histogram.items()), key=operator.itemgetter(1))[0]
out.putpixel((x, y), color)
Pixelate Image With Pillow