From bfd242ca8755782d50891e9d319605d231261cbf Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 21 May 2019 23:20:47 +0200 Subject: [PATCH] added argparse --- print.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/print.py b/print.py index b511af7..fe3cdf7 100644 --- a/print.py +++ b/print.py @@ -1,3 +1,4 @@ +import argparse import sys import os import six @@ -57,15 +58,19 @@ def _int_low_high(inp_number, out_bytes): return outp -filename = u"img.jpg" +parser = argparse.ArgumentParser(description='Process some imagefile') +parser.add_argument('--img',dest="img", + help='pass image to print') +args = parser.parse_args() +filename = args.img im = Image.open(filename) -basewidth = 600 +basewidth = 350 # Initial rotate. mirror, and extract blobs for each 8 or 24-pixel row # Convert to black & white via greyscale (so that bits can be inverted) im = im.transpose(Image.ROTATE_270).transpose(Image.FLIP_LEFT_RIGHT) -width_pixels,height_pixels = im.size +height_pixels, width_pixels = im.size if width_pixels > basewidth: wpercent = (basewidth/float(im.size[0]))