FridaKahlosArtCenter commited on
Commit
4004d5e
1 Parent(s): eb29344

set the version of pillow

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. requirements.txt +1 -1
app.py CHANGED
@@ -75,8 +75,8 @@ def image_to_template(generated_image, logo, button_text, punchline, theme_color
75
  ]
76
 
77
  # Generate Components
78
- generated_image.thumbnail(image_shape, Image.LANCZOS)
79
- logo.thumbnail(logo_shape, Image.LANCZOS)
80
  background = Image.new("RGBA", (template_width, template_height), "WHITE")
81
  # round the corners of generated image
82
  mask = Image.new("L", generated_image.size, 0)
@@ -94,7 +94,7 @@ def image_to_template(generated_image, logo, button_text, punchline, theme_color
94
  # Punchline text
95
  text_heights = []
96
  for line in punchline:
97
- text_width, text_height = draw.textlength(line, font=punchline_font)
98
  punchline_pos = (
99
  (template_width - text_width) // 2,
100
  image_pos[1] + generated_image.height + margin + sum(text_heights),
@@ -103,7 +103,7 @@ def image_to_template(generated_image, logo, button_text, punchline, theme_color
103
  text_heights.append(text_height)
104
 
105
  # Button with rounded corners
106
- button_text_width, button_text_height = draw.textlength(button_text, font=button_font)
107
  button_shape = [
108
  ((template_width - button_width) // 2, punchline_pos[1] + text_height + margin),
109
  (
 
75
  ]
76
 
77
  # Generate Components
78
+ generated_image.thumbnail(image_shape, Image.ANTIALIAS)
79
+ logo.thumbnail(logo_shape, Image.ANTIALIAS)
80
  background = Image.new("RGBA", (template_width, template_height), "WHITE")
81
  # round the corners of generated image
82
  mask = Image.new("L", generated_image.size, 0)
 
94
  # Punchline text
95
  text_heights = []
96
  for line in punchline:
97
+ text_width, text_height = draw.textsize(line, font=punchline_font)
98
  punchline_pos = (
99
  (template_width - text_width) // 2,
100
  image_pos[1] + generated_image.height + margin + sum(text_heights),
 
103
  text_heights.append(text_height)
104
 
105
  # Button with rounded corners
106
+ button_text_width, button_text_height = draw.textsize(button_text, font=button_font)
107
  button_shape = [
108
  ((template_width - button_width) // 2, punchline_pos[1] + text_height + margin),
109
  (
requirements.txt CHANGED
@@ -3,7 +3,7 @@ transformers
3
  --extra-index-url https://download.pytorch.org/whl/cu113
4
  torch
5
  gradio
6
- pillow
7
  requests
8
  safetensors
9
  accelerate
 
3
  --extra-index-url https://download.pytorch.org/whl/cu113
4
  torch
5
  gradio
6
+ pillow==9.4.0
7
  requests
8
  safetensors
9
  accelerate