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"])
