Spaces:
Runtime error
Runtime error
Update overlay.py
Browse files- overlay.py +6 -6
overlay.py
CHANGED
|
@@ -2,9 +2,9 @@ import cv2
|
|
| 2 |
from PIL import ImageFont, ImageDraw, Image
|
| 3 |
|
| 4 |
def process(img,font_text,font_fac,font_x,font_y,font_col,font_op):
|
| 5 |
-
|
| 6 |
|
| 7 |
-
img = Image.open(
|
| 8 |
im=img
|
| 9 |
#im=Image.open(img)
|
| 10 |
txt = Image.new('RGBA', im.size, (255,255,255,0))
|
|
@@ -36,9 +36,8 @@ def process(img,font_text,font_fac,font_x,font_y,font_col,font_op):
|
|
| 36 |
#txt.putalpha(128)
|
| 37 |
|
| 38 |
combined = Image.alpha_composite(im, txt)
|
| 39 |
-
combined
|
| 40 |
-
|
| 41 |
-
|
| 42 |
def textover(im,txt):
|
| 43 |
#im.save('tmp.png')
|
| 44 |
|
|
@@ -62,8 +61,9 @@ def textover(im,txt):
|
|
| 62 |
font_y = h-hhh
|
| 63 |
out = process(im,txt,font_fac=font_a,font_x=font_x,font_y=hh,font_col="#000000",font_op=255)
|
| 64 |
out = process(out,"Contact Card",font_fac=font_b,font_x=font_x,font_y=font_y,font_col="#000000",font_op=255)
|
|
|
|
| 65 |
|
| 66 |
-
return out
|
| 67 |
|
| 68 |
def background_image():
|
| 69 |
img_b = np.zeros([512,512,3],dtype=np.uint8)
|
|
|
|
| 2 |
from PIL import ImageFont, ImageDraw, Image
|
| 3 |
|
| 4 |
def process(img,font_text,font_fac,font_x,font_y,font_col,font_op):
|
| 5 |
+
img.save('tmp.png')
|
| 6 |
|
| 7 |
+
img = Image.open('tmp.png').convert("RGBA")
|
| 8 |
im=img
|
| 9 |
#im=Image.open(img)
|
| 10 |
txt = Image.new('RGBA', im.size, (255,255,255,0))
|
|
|
|
| 36 |
#txt.putalpha(128)
|
| 37 |
|
| 38 |
combined = Image.alpha_composite(im, txt)
|
| 39 |
+
return combined
|
| 40 |
+
|
|
|
|
| 41 |
def textover(im,txt):
|
| 42 |
#im.save('tmp.png')
|
| 43 |
|
|
|
|
| 61 |
font_y = h-hhh
|
| 62 |
out = process(im,txt,font_fac=font_a,font_x=font_x,font_y=hh,font_col="#000000",font_op=255)
|
| 63 |
out = process(out,"Contact Card",font_fac=font_b,font_x=font_x,font_y=font_y,font_col="#000000",font_op=255)
|
| 64 |
+
out.save("out.png")
|
| 65 |
|
| 66 |
+
return "out.png"
|
| 67 |
|
| 68 |
def background_image():
|
| 69 |
img_b = np.zeros([512,512,3],dtype=np.uint8)
|