def compress_file(filename): image = open(filename, 'rb').read() image = transpose_tiles(image) pic = compress(image) pic = bytearray(pic) output_filename = os.path.splitext(filename)[0] + '.pic' with open(output_filename, 'wb') as out: out.write(pic)
def decompress_file(filename): """ Decompress a pic given a filename. Export the resulting planar 2bpp image to """ pic = open(filename, 'rb') image = decompress(pic) image = transpose_tiles(image) image = bytearray(image) output_filename = os.path.splitext(filename)[0] + '.2bpp' with open(output_filename, 'wb') as out: out.write(image)