From d218a01e4dcf5d6c2376c2c6ffac5ef6455bb946 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Mon, 25 Jan 2021 18:45:59 +0100 Subject: [PATCH] Image generation --- ascii_bin-image.jpg | Bin 0 -> 791 bytes ascii_bin.py | 8 +++++--- generator.py | 10 +++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 ascii_bin-image.jpg diff --git a/ascii_bin-image.jpg b/ascii_bin-image.jpg new file mode 100644 index 0000000000000000000000000000000000000000..996b84974f30ceaa37463fcda06efff186f8de0d GIT binary patch literal 791 zcmex=^(PF6}rMnOeST|r4lSw=>~TvNxu(8R<c1}I=;VrF4wW9Q)H;sz?% zD!{d!pzFb!U9xX3zTPI5o8roG<0MW4oqZMDikqloVbuf*=gfJ(V&YTRE(2~ znmD<{#3dx9RMpfqG__1j&CD$#!@AQ;?`G^Osd~FjZSvt?;ZypnpRjEfJ}j;C zi6ym9Y|4@a>s}VD-+4ixIqzKc>w4CTEbnNIFRRabyZhR%`}22Q+SIUn7ZyKgieS`f zvhi5WQ{5@J%HDA4tKj;~7hS8RVjT+?+=#x{;Pb(`G{t np.array: return col_array -def main(inp:list) -> None: +def generate(inp:list) -> None: col_array = data_to_matrix(inp) - img = smp.toimage(col_array) - img.show() + img = Image.fromarray(col_array, "RGB") + img.save("ascii_bin-image.jpg") diff --git a/generator.py b/generator.py index 8cec4d7..653dfde 100755 --- a/generator.py +++ b/generator.py @@ -1,10 +1,10 @@ #!/usr/bin/env python import sys -from ascii_bin import main as ascii_bin +import ascii_bin method_pointers = { - "ascii_bin": ascii_bin + "ascii_bin": ascii_bin.generate } @@ -24,4 +24,8 @@ def generate_image(file:str, method:str = "ascii_bin", bytesize:int = 8) -> None if __name__ == "__main__": - generate_image(sys.argv[3], sys.argv[1], int(sys.argv[2])) + try: + generate_image(sys.argv[3], sys.argv[1], int(sys.argv[2])) + except Exception as err: + print("\033[91m./generator.py (method:str) (bytesize:int) (dimensions:str (WxH)) (input_file:str)\033[0m") + raise err