Template filler
This commit is contained in:
20
chr2pix
20
chr2pix
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user