Spaces:
Running
Running
Deniel Dimitrov
commited on
Commit
Β·
578cc47
1
Parent(s):
d883fba
Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,14 @@ from PIL import Image, ImageTk
|
|
3 |
import gradio as gr
|
4 |
|
5 |
def convert_to_ascii(image,text_size):
|
6 |
-
|
|
|
|
|
7 |
aspect_ratio = height / width
|
8 |
new_width = int(text_size)
|
9 |
new_height = int(aspect_ratio * text_size * 0.5)
|
10 |
|
11 |
-
resized_image =
|
12 |
grayscale_image = resized_image.convert('L')
|
13 |
|
14 |
ascii_chars = 'β@&%#*β+=-:,.\/|][}{)(Β΄βββββ ' # add more characters if you want
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
def convert_to_ascii(image,text_size):
|
6 |
+
gimage = Image.open(image)
|
7 |
+
|
8 |
+
width, height = gimage.size
|
9 |
aspect_ratio = height / width
|
10 |
new_width = int(text_size)
|
11 |
new_height = int(aspect_ratio * text_size * 0.5)
|
12 |
|
13 |
+
resized_image = gimage.resize((new_width, new_height))
|
14 |
grayscale_image = resized_image.convert('L')
|
15 |
|
16 |
ascii_chars = 'β@&%#*β+=-:,.\/|][}{)(Β΄βββββ ' # add more characters if you want
|