'Turn a (small) binary image into a string representation'

def img_to_string(self, im):

    chars = '.1'
    (width, height) = im.size
    return '\n'.join((''.join((chars[(im.getpixel((c, r)) > 0)] for c in range(width))) for r in range(height)))
