Taka005 commited on
Commit
31ac6cb
·
1 Parent(s): a34a680
Files changed (1) hide show
  1. main.py +7 -9
main.py CHANGED
@@ -9,7 +9,7 @@ ICON = 'icon.png'
9
 
10
  MPLUS_FONT_16 = ImageFont.truetype("fonts/MPLUSRounded1c-Regular.ttf", size=16)
11
 
12
- 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, emojis: list = [], disable_dot_wrap=False):
13
 
14
  draw = ImageDraw.Draw(im)
15
  fontObj = ImageFont.truetype(font, size=size)
@@ -67,7 +67,7 @@ def draw_text(im, ofs, string, font="fonts/MPLUSRounded1c-Regular.ttf", size=16,
67
  adj_y = -30 * (len(draw_lines)-1)
68
  for dl in draw_lines:
69
  with Pilmoji(im) as p:
70
- p.text((dl[0], (adj_y + dl[1])), dl[2], font=fontObj, fill=color, emojis=emojis, emoji_position_offset=(-4, 4))
71
 
72
  real_y = ofs[1] + adj_y + dy
73
 
@@ -78,7 +78,7 @@ content = "こっっっっっっっっっっbれってなんですかね?知
78
  img = BASE_WHITE_IMAGE.copy()
79
 
80
  icon = Image.open(ICON)
81
- icon = icon.resize((720, 720), Image.ANTIALIAS)
82
  icon = icon.convert("L")
83
  icon_filtered = ImageEnhance.Brightness(icon)
84
 
@@ -90,22 +90,20 @@ img.paste(BASE_GRADATION_IMAGE, (0,0), BASE_GRADATION_IMAGE)
90
  # テキスト合成
91
  tx = ImageDraw.Draw(img)
92
 
93
- base_x = 890
94
-
95
  # 文章描画
96
- tsize_t = draw_text(img, (base_x, 270), content, size=45, color=(255,255,255,255), split_len=16, auto_expand=True)
97
 
98
  # 名前描画
99
  uname = 'Taka005#6668'
100
  name_y = tsize_t[2] + 40
101
- tsize_name = draw_text(img, (base_x, name_y), uname, size=25, color=(255,255,255,255), split_len=25, disable_dot_wrap=True)
102
 
103
  # ID描画
104
  id = '000000000000'
105
  id_y = name_y + tsize_name[1] + 4
106
- tsize_id = draw_text(img, (base_x, id_y), f"({id})", size=18, color=(180,180,180,255), split_len=45, disable_dot_wrap=True)
107
 
108
  # クレジット
109
  tx.text((1125, 694), "TakasumiBOT#7189", font=MPLUS_FONT_16, fill=(120,120,120,255))
110
 
111
- img.save("quote.png", quality=95)
 
9
 
10
  MPLUS_FONT_16 = ImageFont.truetype("fonts/MPLUSRounded1c-Regular.ttf", size=16)
11
 
12
+ 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):
13
 
14
  draw = ImageDraw.Draw(im)
15
  fontObj = ImageFont.truetype(font, size=size)
 
67
  adj_y = -30 * (len(draw_lines)-1)
68
  for dl in draw_lines:
69
  with Pilmoji(im) as p:
70
+ p.text((dl[0], (adj_y + dl[1])), dl[2], font=fontObj, fill=color)
71
 
72
  real_y = ofs[1] + adj_y + dy
73
 
 
78
  img = BASE_WHITE_IMAGE.copy()
79
 
80
  icon = Image.open(ICON)
81
+ icon = icon.resize((720, 720), Image.LANCZOS)
82
  icon = icon.convert("L")
83
  icon_filtered = ImageEnhance.Brightness(icon)
84
 
 
90
  # テキスト合成
91
  tx = ImageDraw.Draw(img)
92
 
 
 
93
  # 文章描画
94
+ tsize_t = draw_text(img, (890, 270), content, size=45, color=(255,255,255,255), split_len=16, auto_expand=True)
95
 
96
  # 名前描画
97
  uname = 'Taka005#6668'
98
  name_y = tsize_t[2] + 40
99
+ tsize_name = draw_text(img, (890, name_y), uname, size=25, color=(255,255,255,255), split_len=25, disable_dot_wrap=True)
100
 
101
  # ID描画
102
  id = '000000000000'
103
  id_y = name_y + tsize_name[1] + 4
104
+ tsize_id = draw_text(img, (890, id_y), f"({id})", size=18, color=(180,180,180,255), split_len=45, disable_dot_wrap=True)
105
 
106
  # クレジット
107
  tx.text((1125, 694), "TakasumiBOT#7189", font=MPLUS_FONT_16, fill=(120,120,120,255))
108
 
109
+ img.save("quote.png", quality=100)