We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0a36faa + f749dbd commit 3d6db8aCopy full SHA for 3d6db8a
ascii.py
@@ -128,7 +128,13 @@ def terminal_artify(self):
128
for w in range(current_w):
129
# get brightness value
130
brightness = grayscale_img.getpixel((w, h))/255.0
131
- srgb = [ (v/255.0)**2.2 for v in canvas.getpixel((w,h)) ]
+ pixel = canvas.getpixel((w, h))
132
+ # getpixel() may return an int, instead of tuple of ints, if the
133
+ # source img is a PNG with a transparency layer.
134
+ if isinstance(pixel, int):
135
+ pixel = (pixel, pixel, 255)
136
+
137
+ srgb = [ (v/255.0)**2.2 for v in pixel ]
138
139
# select required character from the letter_densities list
140
char_pos = brightness * (len(self.letter_densities) - 1)
0 commit comments