From cc78846506a2fa6063a40226b123b895c2c7a237 Mon Sep 17 00:00:00 2001 From: Brett Kuprel Date: Thu, 14 Jul 2022 11:28:03 -0400 Subject: [PATCH] gray_pixels not rgb_pixels --- image_from_text.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/image_from_text.py b/image_from_text.py index a826012..2d1df22 100644 --- a/image_from_text.py +++ b/image_from_text.py @@ -17,9 +17,9 @@ parser.add_argument('--top_k', type=int, default=256) def ascii_from_image(image: Image.Image, size: int = 128) -> str: - rgb_pixels = image.resize((size, int(0.55 * size))).convert('L').getdata() + gray_pixels = image.resize((size, int(0.55 * size))).convert('L').getdata() chars = list('.,;/IOX') - chars = [chars[i * len(chars) // 256] for i in rgb_pixels] + chars = [chars[i * len(chars) // 256] for i in gray_pixels] chars = [chars[i * size: (i + 1) * size] for i in range(size // 2)] return '\n'.join(''.join(row) for row in chars)