Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,12 +8,25 @@ import uuid
|
|
8 |
|
9 |
client = Client("ysharma/BiRefNet_for_text_writing")
|
10 |
|
11 |
-
def
|
12 |
-
"""Helper function to draw text with stroke"""
|
13 |
-
# Draw
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def remove_background(image):
|
19 |
# Save the image to a specific location
|
@@ -221,7 +234,7 @@ def create_interface():
|
|
221 |
x_position,
|
222 |
y_position,
|
223 |
thickness,
|
224 |
-
shadow_checkbox
|
225 |
],
|
226 |
outputs=output_image,
|
227 |
fn=add_text_to_image,
|
|
|
8 |
|
9 |
client = Client("ysharma/BiRefNet_for_text_writing")
|
10 |
|
11 |
+
def add_text_with_effects(draw, text, x, y, font, text_color, stroke_width, shadow=False, shadow_offset=(5, 5)):
|
12 |
+
"""Helper function to draw text with stroke and optional shadow"""
|
13 |
+
# Draw shadow first if enabled
|
14 |
+
if shadow:
|
15 |
+
# Create shadow color (darker version of text color or black)
|
16 |
+
shadow_color = (0, 0, 0, text_color[3]) # Black with same opacity as text
|
17 |
+
|
18 |
+
# Draw the shadow text with stroke effect
|
19 |
+
shadow_x = x + shadow_offset[0]
|
20 |
+
shadow_y = y + shadow_offset[1]
|
21 |
+
|
22 |
+
for adj_x in range(-stroke_width, stroke_width + 1):
|
23 |
+
for adj_y in range(-stroke_width, stroke_width + 1):
|
24 |
+
draw.text(
|
25 |
+
(shadow_x + adj_x, shadow_y + adj_y),
|
26 |
+
text,
|
27 |
+
font=font,
|
28 |
+
fill=shadow_color
|
29 |
+
)
|
30 |
|
31 |
def remove_background(image):
|
32 |
# Save the image to a specific location
|
|
|
234 |
x_position,
|
235 |
y_position,
|
236 |
thickness,
|
237 |
+
shadow_checkbox,
|
238 |
],
|
239 |
outputs=output_image,
|
240 |
fn=add_text_to_image,
|