Image generation

master
E. Almqvist 4 years ago
parent 4cc040c641
commit d218a01e4d
  1. BIN
      ascii_bin-image.jpg
  2. 8
      ascii_bin.py
  3. 8
      generator.py

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

@ -1,5 +1,7 @@
import numpy as np import numpy as np
import scipy.misc as smp import scipy.misc as smp
from PIL import Image
bit_on = [255, 255, 255] # RGB value if bit is 1 bit_on = [255, 255, 255] # RGB value if bit is 1
bit_off = [0, 0, 0] # RGB value if bit is 0 bit_off = [0, 0, 0] # RGB value if bit is 0
@ -16,8 +18,8 @@ def data_to_matrix(data:list) -> np.array:
return col_array return col_array
def main(inp:list) -> None: def generate(inp:list) -> None:
col_array = data_to_matrix(inp) col_array = data_to_matrix(inp)
img = smp.toimage(col_array) img = Image.fromarray(col_array, "RGB")
img.show() img.save("ascii_bin-image.jpg")

@ -1,10 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys import sys
from ascii_bin import main as ascii_bin import ascii_bin
method_pointers = { 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__": if __name__ == "__main__":
try:
generate_image(sys.argv[3], sys.argv[1], int(sys.argv[2])) 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

Loading…
Cancel
Save