#!/usr/bin/env python # -*- mode: python; Encoding: utf-8; coding: utf-8 -*- # Last updated: <2015/12/04 07:52:36 +0900> """ 8x8ドットのフォントが縦方向で敷き詰められた画像に対して横方向に並び替える """ import sys from PIL import Image def main(): if len(sys.argv) != 3: print "usage: conv_h_v.py INPUT.png OUTPUT.png" sys.exit() infile = sys.argv[1] outfile = sys.argv[2] cw, ch = 8, 8 img = Image.open(infile).convert("RGB") w, h = img.size nimg = Image.new("RGB", (w, h)) for x in range(w / cw): for y in range(h / cw): timg = img.crop((x * cw, y * ch, w, h)) nimg.paste(timg, (y * ch, x * cw)) nimg.save(outfile) if __name__ == '__main__': main()