Deniel Dimitrov commited on
Commit
578cc47
Β·
1 Parent(s): d883fba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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
- width, height = image.size
 
 
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 = image.resize((new_width, new_height))
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