Taka005 commited on
Commit
6f360cf
·
1 Parent(s): cd6bd2c
Files changed (1) hide show
  1. main.py +2 -42
main.py CHANGED
@@ -74,8 +74,7 @@ def draw_text(im, ofs, string, font="fonts/MPLUSRounded1c-Regular.ttf", size=16,
74
 
75
  return (0, dy, real_y)
76
 
77
- # ノーマル
78
- def normal_gen(name, tag, id, content, icon):
79
  img = BASE_IMAGE.copy()
80
 
81
  icon = Image.open(io.BytesIO(requests.get(icon).content))
@@ -103,50 +102,11 @@ def normal_gen(name, tag, id, content, icon):
103
  file.seek(0)
104
  return file
105
 
106
- #色なし
107
- def color_gen(name, tag, id, content, icon):
108
- img = BASE_IMAGE.copy()
109
-
110
- icon = Image.open(io.BytesIO(requests.get(icon).content))
111
- icon = icon.resize((720, 720), Image.LANCZOS)
112
- icon_filtered = ImageEnhance.Brightness(icon)
113
-
114
- img.paste(icon_filtered.enhance(0.7), (0, 0))
115
- img.paste(BASE_GD_IMAGE, (0, 0), BASE_GD_IMAGE)
116
-
117
- tx = ImageDraw.Draw(img)
118
-
119
- tsize_t = draw_text(img, (890, 270), content, size=45, color=(255, 255, 255, 255), split_len=16, auto_expand=True)
120
-
121
- name_y = tsize_t[2] + 40
122
- tsize_name = draw_text(img, (890, name_y), f"{name}#{tag}", size=25, color=(255, 255, 255, 255), split_len=25, disable_dot_wrap=True)
123
-
124
- id_y = name_y + tsize_name[1] + 4
125
- tsize_id = draw_text(img, (890, id_y), id, size=18, color=(180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
126
-
127
- tx.text((1125, 694), "TakasumBOT#7189",font=MPLUS_FONT, fill=(120, 120, 120, 255))
128
-
129
- file = io.BytesIO()
130
- img.save(file, format="PNG", quality=95)
131
- file.seek(0)
132
- return file
133
-
134
  app = Flask(__name__)
135
 
136
  @app.route("/", methods=["GET"])
137
  def normal():
138
- res = normal_gen(
139
- request.args.get("name") or "名無し",
140
- request.args.get("tag") or "0000",
141
- request.args.get("id") or "0000000000000000000",
142
- request.args.get("content") or "これはテストです",
143
- request.args.get("icon") or "https://cdn.discordapp.com/embed/avatars/0.png"
144
- )
145
- return send_file(res, mimetype="image/png")
146
-
147
- @app.route("/color", methods=["GET"])
148
- def color():
149
- res = color_gen(
150
  request.args.get("name") or "名無し",
151
  request.args.get("tag") or "0000",
152
  request.args.get("id") or "0000000000000000000",
 
74
 
75
  return (0, dy, real_y)
76
 
77
+ def gen(name, tag, id, content, icon):
 
78
  img = BASE_IMAGE.copy()
79
 
80
  icon = Image.open(io.BytesIO(requests.get(icon).content))
 
102
  file.seek(0)
103
  return file
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  app = Flask(__name__)
106
 
107
  @app.route("/", methods=["GET"])
108
  def normal():
109
+ res = gen(
 
 
 
 
 
 
 
 
 
 
 
110
  request.args.get("name") or "名無し",
111
  request.args.get("tag") or "0000",
112
  request.args.get("id") or "0000000000000000000",