Author SHA1 Message Date
dqnid ffd13421ca feat: ascii parser base code 2026-02-13 14:59:25 +01:00
5 changed files with 40 additions and 14 deletions

No files matched your search

-12
View File
@@ -8,15 +8,3 @@ arboard = "3.6.0"
colored = "3.0.0" colored = "3.0.0"
inquire = "0.7.5" inquire = "0.7.5"
regex = "1.11.1" regex = "1.11.1"
[profile.release]
opt-level = "s"
debug = false
strip = "debuginfo"
debug-assertions = false
overflow-checks = false
lto = false
panic = 'unwind'
incremental = false
codegen-units = 16
rpath = false
-2
View File
@@ -2,8 +2,6 @@
Simple CLI color parser. Reads the color to be parsed either from the clipboard, from and input argument or directly from the user keyboard manual input. Simple CLI color parser. Reads the color to be parsed either from the clipboard, from and input argument or directly from the user keyboard manual input.
## Building
## Arguments ## Arguments
The program allows one of these 2 arguments: The program allows one of these 2 arguments:
Binary file not shown.

After

Width:  |  Height:  |  Size: 931 KiB

@@ -0,0 +1,36 @@
from PIL import Image
def convert_ascii(src: str, width: int, weight: int, charset: [str]):
# Open an image file
img = Image.open(src)
gray_scale = len(charset)
print("__char", charset, gray_scale)
img_width, img_height = img.size
px = img.load()
# Use image parser to take resolution down
# Convert to grayscale
# Calc color differences
# Stablish defined character based on the color variance
min_color = 255
max_color = 0
for x in range(img_width):
for y in range(img_height):
# r, g, b = px[x, y]
gray_px = sum(px[x, y]) // 3
px[x,y] = (gray_px, gray_px, gray_px)
if (min_color > gray_px):
min_color = gray_px
elif (max_color < gray_px):
max_color = gray_px
print("Pixels", px[0,0], min_color, max_color) # --> outputs a three-dimensional array, rgb
convert_ascii('src/assets/fee.jpg', 100, 100, ["a", "b", "c"])
convert_ascii('src/assets/clear.jpg', 100, 100, ["a", "b", "c"])
@@ -0,0 +1,4 @@
class TestAsciiConvert:
def test_pixel_parse(self):
print("__testing")
assert 1 + 1 == 2