Spaces:
Running
Running
Taka005
commited on
Commit
·
23e5a2c
1
Parent(s):
c2743bd
変数変更
Browse files
main.py
CHANGED
|
@@ -6,12 +6,12 @@ import warnings
|
|
| 6 |
# 警告無効化
|
| 7 |
warnings.simplefilter("ignore")
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
ICON = 'icon.png'
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
def draw_text(im,ofs,string,font="fonts/MPLUSRounded1c-Regular.ttf",size=16,color=(0,0,0,255),split_len=None,padding=4,auto_expand=False,disable_dot_wrap=False):
|
| 17 |
|
|
@@ -79,7 +79,7 @@ def draw_text(im,ofs,string,font="fonts/MPLUSRounded1c-Regular.ttf",size=16,colo
|
|
| 79 |
|
| 80 |
content = "これはテストで生成されたものです"
|
| 81 |
|
| 82 |
-
img =
|
| 83 |
|
| 84 |
icon = Image.open(ICON)
|
| 85 |
icon = icon.resize((720,720),Image.LANCZOS)
|
|
@@ -89,7 +89,7 @@ icon_filtered = ImageEnhance.Brightness(icon)
|
|
| 89 |
img.paste(icon_filtered.enhance(0.7),(0,0))
|
| 90 |
|
| 91 |
# グラデーション描画
|
| 92 |
-
img.paste(
|
| 93 |
|
| 94 |
# テキスト
|
| 95 |
tx = ImageDraw.Draw(img)
|
|
@@ -108,6 +108,6 @@ id_y = name_y + tsize_name[1] + 4
|
|
| 108 |
tsize_id = draw_text(img,(890,id_y),f"({id})",size=18,color=(180,180,180,255),split_len=45,disable_dot_wrap=True)
|
| 109 |
|
| 110 |
# TakasumiBOT描画
|
| 111 |
-
tx.text((1125, 694),"TakasumiBOT#7189",font=
|
| 112 |
|
| 113 |
img.save("quote.png",quality=100)
|
|
|
|
| 6 |
# 警告無効化
|
| 7 |
warnings.simplefilter("ignore")
|
| 8 |
|
| 9 |
+
BASE_GD_IMAGE = Image.open("images/base-gd.png")
|
| 10 |
+
BASE_IMAGE = Image.open("images/base.png")
|
| 11 |
|
| 12 |
ICON = 'icon.png'
|
| 13 |
|
| 14 |
+
MPLUS_FONT = ImageFont.truetype("fonts/MPLUSRounded1c-Regular.ttf", size=16)
|
| 15 |
|
| 16 |
def draw_text(im,ofs,string,font="fonts/MPLUSRounded1c-Regular.ttf",size=16,color=(0,0,0,255),split_len=None,padding=4,auto_expand=False,disable_dot_wrap=False):
|
| 17 |
|
|
|
|
| 79 |
|
| 80 |
content = "これはテストで生成されたものです"
|
| 81 |
|
| 82 |
+
img = BASE_IMAGE.copy()
|
| 83 |
|
| 84 |
icon = Image.open(ICON)
|
| 85 |
icon = icon.resize((720,720),Image.LANCZOS)
|
|
|
|
| 89 |
img.paste(icon_filtered.enhance(0.7),(0,0))
|
| 90 |
|
| 91 |
# グラデーション描画
|
| 92 |
+
img.paste(BASE_GD_IMAGE,(0,0),BASE_GD_IMAGE)
|
| 93 |
|
| 94 |
# テキスト
|
| 95 |
tx = ImageDraw.Draw(img)
|
|
|
|
| 108 |
tsize_id = draw_text(img,(890,id_y),f"({id})",size=18,color=(180,180,180,255),split_len=45,disable_dot_wrap=True)
|
| 109 |
|
| 110 |
# TakasumiBOT描画
|
| 111 |
+
tx.text((1125, 694),"TakasumiBOT#7189",font=MPLUS_FONT,fill=(120,120,120,255))
|
| 112 |
|
| 113 |
img.save("quote.png",quality=100)
|