diff --git a/a.png b/a.png new file mode 100644 index 0000000..77f72cc Binary files /dev/null and b/a.png differ diff --git a/main.py b/main.py index 82aa600..6394a3b 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,12 @@ import numpy as np import PIL from dataclasses import dataclass -img = './b.png' +img = './a.png' +character = '#' +size = (170, 200) +# size=(4,4) +# size=(1,1) + scale = 1 windows: bool = True @@ -61,7 +66,7 @@ if windows: # text=f'{Fore.RED}TEst{Fore.RESET}' # pyperclip.copy(text) -# text=f"redred" +# text=f"redred" # text2=f"{Fore.RED}red{Fore.RESET}red" # text3=f"{Fore.RED}red{Fore.RESET}red".encode().replace(b'\x1b[',b'\x1b[2;').decode() # print(text) @@ -95,7 +100,7 @@ if windows: img_data = PIL.Image.open(img) # print(img_data.info) -img_data = img_data.resize((2, 2), Resampling.NEAREST) +img_data = img_data.resize(size, Resampling.NEAREST) img_arr = np.array(img_data) h, w = img_data.size print(h) @@ -124,35 +129,38 @@ for n, pxl_line in enumerate(img_arr): # rgb_map[n] = [] rgb_map_line = rgb_map[n] for pxl in pxl_line: - print(pxl) - r, g, b, _ = pxl - print(r, g, b) + # print(pxl) + r, g, b = pxl[:3] + # print(r, g, b) _rgb = RGB(red=r, green=g, blue=b) - print(f'>> {_rgb.__str__()}') rgb_map_line.append(_rgb) - # rgb_map_line.append('') +# print(f'>> {_rgb.__str__()}') +# rgb_map_line.append('') txt = "" -character = '#' - - txt += """```ansi\n""" for line in rgb_map: for rgb in line: rgb: RGB # print(rgb) - # txt += rgb.__hex__() - txt += rgb + + ansi = fg(f'#{rgb.__hex__()}') + # print(f'>> {rgb.__str__()}') + txt += ansi txt += '#' - txt += '\n' + txt += '\n' +txt += attr('reset') txt += """```""" print(txt) -pyperclip.copy(txt) +# print(txt.encode()) + +# pyperclip.copy(txt) + # x = """ -# TEXT -# FF +# TEXT +# FF # """ # print(x.encode())