from PIL import Image
import sys
import numpy as np

img = Image.open(sys.argv[1])
arr = np.array(img)

num_rows, num_cols = arr.shape
num_rows //= 16
num_cols //= 10

letters = []

for row in range(num_rows):
    for col in range(num_cols):
        pixels = arr[row*16:(row+1)*16, col*10:(col+1)*10]
        letters.append(pixels)

outarray = np.hstack(letters)

newimg = Image.fromarray(outarray)
newimg.putpalette(b'\x00\x00\x00\xff\xff\xff')
newimg.save(sys.argv[2])
