Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions asciify.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def modify(image, buckets=25):
- does all the work by calling all the above functions
'''
def do(image, new_width=100):
image = resize(image)
image = resize(image, new_width)
image = grayscalify(image)

pixels = modify(image)
Expand All @@ -54,15 +54,15 @@ def do(image, new_width=100):
- handles exceptions as well
- provides alternative output options
'''
def runner(path):
def runner(path, width):
image = None
try:
image = Image.open(path)
except Exception:
print("Unable to find image in",path)
#print(e)
return
image = do(image)
image = do(image, width)

# To print on console
print(image)
Expand All @@ -88,4 +88,10 @@ def runner(path):
path = "asciify.jpg"
else:
path = sys.argv[1]
runner(path)

if len(sys.argv) >= 3:
width = int(sys.argv[2])
else:
width = 100

runner(path, width)