master
E. Almqvist 4 years ago
parent d218a01e4d
commit 80f5a7a659
  1. 1
      .gitignore
  2. 5
      generator.py
  3. 7
      methods/ascii_bin.py

1
.gitignore vendored

@ -1,2 +1,3 @@
*.py[cod]
documentation/
*.jpg

@ -1,7 +1,7 @@
#!/usr/bin/env python
import sys
import ascii_bin
from methods import ascii_bin
method_pointers = {
"ascii_bin": ascii_bin.generate
@ -18,6 +18,7 @@ def get_input(file:str, bytesize:int = 8) -> list:
return [ f_str[i:i+bytesize] for i in range(0, len(f_str), bytesize) ]
def generate_image(file:str, method:str = "ascii_bin", bytesize:int = 8) -> None:
print("Formatting and converting input data...")
inp = get_input(file, bytesize)
method_pointers[method](inp)
@ -27,5 +28,5 @@ if __name__ == "__main__":
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")
print("\033[91m./generator.py (method:str) (bytesize:int) (input_file:str)\033[0m")
raise err

@ -3,8 +3,8 @@ import scipy.misc as smp
from PIL import Image
bit_on = [255, 255, 255] # RGB value if bit is 1
bit_off = [0, 0, 0] # RGB value if bit is 0
bit_on = [191, 191, 191] # RGB value if bit is 1
bit_off = [17, 16, 21] # RGB value if bit is 0
def translate_bit_color(bit:str):
if( bit == "1" ):
@ -19,7 +19,10 @@ def data_to_matrix(data:list) -> np.array:
return col_array
def generate(inp:list) -> None:
print("Converting data to matrix...")
col_array = data_to_matrix(inp)
print("Generating image...")
img = Image.fromarray(col_array, "RGB")
img.save("ascii_bin-image.jpg")
print("Generated image \"ascii_bin-image.jpg\"")
Loading…
Cancel
Save