Template filler

This commit is contained in:
q
2015-06-01 21:11:15 +03:00
parent a9a4625d9a
commit 57771e1e8d
3 changed files with 81 additions and 9 deletions

20
chr2pix
View File

@@ -2,6 +2,8 @@
import sys
import scipy.misc
import numpy as n
from argparse import ArgumentParser
def png2asc(inFile):
im=scipy.misc.imread(inFile)
@@ -35,15 +37,15 @@ def asc2png(inFile,outFile):
scipy.misc.imsave(outFile, im)
if len(sys.argv)==1:
print("Arguments:")
print(" [png image file] : prints ascii in stdout")
print(" [text file] [png image file] : convert characters to pixels in image")
sys.exit(0)
inFile = sys.argv[1]
if inFile.lower().endswith('.png'):
png2asc(inFile)
parser=ArgumentParser(description="Convert image to ascii, or ascii to image. If only input is defined, it is assumed as image (PNG).")
parser.add_argument('input', action="store")
parser.add_argument('output', action="store", nargs='?')
opts=parser.parse_args()
if opts.output==None:
png2asc(opts.input)
else:
asc2png(inFile,sys.argv[2])
asc2png(opts.input,opts.output)