added argparse

master
Your Name 6 years ago
parent 5feb8a2cca
commit bfd242ca87

@ -1,3 +1,4 @@
import argparse
import sys import sys
import os import os
import six import six
@ -57,15 +58,19 @@ def _int_low_high(inp_number, out_bytes):
return outp 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) im = Image.open(filename)
basewidth = 600 basewidth = 350
# Initial rotate. mirror, and extract blobs for each 8 or 24-pixel row # 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) # Convert to black & white via greyscale (so that bits can be inverted)
im = im.transpose(Image.ROTATE_270).transpose(Image.FLIP_LEFT_RIGHT) 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: if width_pixels > basewidth:
wpercent = (basewidth/float(im.size[0])) wpercent = (basewidth/float(im.size[0]))

Loading…
Cancel
Save