Spaces:
Building
Building
Taka005
commited on
Commit
·
625d16d
1
Parent(s):
944e5b1
名前変更
Browse files
main.py
CHANGED
@@ -20,7 +20,7 @@ BASE_IMAGE = Image.open("images/base.png")
|
|
20 |
MPLUS_FONT = ImageFont.truetype("fonts/MPLUSRounded1c-Regular.ttf", size=16)
|
21 |
BRAND = "TakasumiBOT#7189"
|
22 |
|
23 |
-
def
|
24 |
draw = ImageDraw.Draw(im)
|
25 |
fontObj = ImageFont.truetype(font, size=size)
|
26 |
|
@@ -93,13 +93,13 @@ def make(name, tag, id, content, icon):
|
|
93 |
|
94 |
tx = ImageDraw.Draw(img)
|
95 |
|
96 |
-
tsize_t =
|
97 |
|
98 |
name_y = tsize_t[2] + 40
|
99 |
-
tsize_name =
|
100 |
|
101 |
id_y = name_y + tsize_name[1] + 4
|
102 |
-
tsize_id =
|
103 |
|
104 |
tx.text((1122, 694), BRAND, font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
105 |
|
@@ -108,7 +108,7 @@ def make(name, tag, id, content, icon):
|
|
108 |
file.seek(0)
|
109 |
return file
|
110 |
|
111 |
-
def
|
112 |
img = BASE_IMAGE.copy()
|
113 |
|
114 |
icon = Image.open(io.BytesIO(requests.get(icon).content))
|
@@ -119,13 +119,13 @@ def colormake(name, tag, id, content, icon):
|
|
119 |
|
120 |
tx = ImageDraw.Draw(img)
|
121 |
|
122 |
-
tsize_t =
|
123 |
|
124 |
name_y = tsize_t[2] + 40
|
125 |
-
tsize_name =
|
126 |
|
127 |
id_y = name_y + tsize_name[1] + 4
|
128 |
-
tsize_id =
|
129 |
|
130 |
tx.text((1122, 694), BRAND,font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
131 |
|
@@ -134,7 +134,7 @@ def colormake(name, tag, id, content, icon):
|
|
134 |
file.seek(0)
|
135 |
return file
|
136 |
|
137 |
-
def
|
138 |
img = BASE_IMAGE.copy()
|
139 |
|
140 |
icon = Image.open(io.BytesIO(requests.get(icon).content))
|
@@ -147,13 +147,13 @@ def reversemake(name, tag, id, content, icon):
|
|
147 |
|
148 |
tx = ImageDraw.Draw(img)
|
149 |
|
150 |
-
tsize_t =
|
151 |
|
152 |
name_y = tsize_t[2] + 40
|
153 |
-
tsize_name =
|
154 |
|
155 |
id_y = name_y + tsize_name[1] + 4
|
156 |
-
tsize_id =
|
157 |
|
158 |
tx.text((6, 694), BRAND,font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
159 |
|
@@ -162,7 +162,7 @@ def reversemake(name, tag, id, content, icon):
|
|
162 |
file.seek(0)
|
163 |
return file
|
164 |
|
165 |
-
def
|
166 |
img = BASE_IMAGE.copy()
|
167 |
|
168 |
icon = Image.open(io.BytesIO(requests.get(icon).content))
|
@@ -175,13 +175,13 @@ def whitemake(name, tag, id, content, icon):
|
|
175 |
|
176 |
tx = ImageDraw.Draw(img)
|
177 |
|
178 |
-
tsize_t =
|
179 |
|
180 |
name_y = tsize_t[2] + 40
|
181 |
-
tsize_name =
|
182 |
|
183 |
id_y = name_y + tsize_name[1] + 4
|
184 |
-
tsize_id =
|
185 |
|
186 |
tx.text((1122, 694), BRAND, font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
187 |
|
@@ -193,7 +193,7 @@ def whitemake(name, tag, id, content, icon):
|
|
193 |
app = Flask(__name__)
|
194 |
|
195 |
@app.route("/", methods=["GET"])
|
196 |
-
def
|
197 |
res = make(
|
198 |
request.args.get("name") or "SAMPLE",
|
199 |
request.args.get("tag") or "1234",
|
@@ -205,7 +205,7 @@ def original():
|
|
205 |
|
206 |
@app.route("/color", methods=["GET"])
|
207 |
def color():
|
208 |
-
res =
|
209 |
request.args.get("name") or "SAMPLE",
|
210 |
request.args.get("tag") or "1234",
|
211 |
request.args.get("id") or "0000000000000000000",
|
@@ -216,7 +216,7 @@ def color():
|
|
216 |
|
217 |
@app.route("/reverse", methods=["GET"])
|
218 |
def reverse():
|
219 |
-
res =
|
220 |
request.args.get("name") or "SAMPLE",
|
221 |
request.args.get("tag") or "1234",
|
222 |
request.args.get("id") or "0000000000000000000",
|
@@ -227,7 +227,7 @@ def reverse():
|
|
227 |
|
228 |
@app.route("/white", methods=["GET"])
|
229 |
def white():
|
230 |
-
res =
|
231 |
request.args.get("name") or "SAMPLE",
|
232 |
request.args.get("tag") or "1234",
|
233 |
request.args.get("id") or "0000000000000000000",
|
|
|
20 |
MPLUS_FONT = ImageFont.truetype("fonts/MPLUSRounded1c-Regular.ttf", size=16)
|
21 |
BRAND = "TakasumiBOT#7189"
|
22 |
|
23 |
+
def drawText(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):
|
24 |
draw = ImageDraw.Draw(im)
|
25 |
fontObj = ImageFont.truetype(font, size=size)
|
26 |
|
|
|
93 |
|
94 |
tx = ImageDraw.Draw(img)
|
95 |
|
96 |
+
tsize_t = drawText(img, (890, 270), content, size=45, color=(255, 255, 255, 255), split_len=16, auto_expand=True)
|
97 |
|
98 |
name_y = tsize_t[2] + 40
|
99 |
+
tsize_name = drawText(img, (890, name_y), f"{name}#{tag}", size=25, color=(255, 255, 255, 255), split_len=25, disable_dot_wrap=True)
|
100 |
|
101 |
id_y = name_y + tsize_name[1] + 4
|
102 |
+
tsize_id = drawText(img, (890, id_y), id, size=18, color=(180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
|
103 |
|
104 |
tx.text((1122, 694), BRAND, font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
105 |
|
|
|
108 |
file.seek(0)
|
109 |
return file
|
110 |
|
111 |
+
def colorMake(name, tag, id, content, icon):
|
112 |
img = BASE_IMAGE.copy()
|
113 |
|
114 |
icon = Image.open(io.BytesIO(requests.get(icon).content))
|
|
|
119 |
|
120 |
tx = ImageDraw.Draw(img)
|
121 |
|
122 |
+
tsize_t = drawText(img, (890, 270), content, size=45, color=(255, 255, 255, 255), split_len=16, auto_expand=True)
|
123 |
|
124 |
name_y = tsize_t[2] + 40
|
125 |
+
tsize_name = drawText(img, (890, name_y), f"{name}#{tag}", size=25, color=(255, 255, 255, 255), split_len=25, disable_dot_wrap=True)
|
126 |
|
127 |
id_y = name_y + tsize_name[1] + 4
|
128 |
+
tsize_id = drawText(img, (890, id_y), id, size=18, color=(180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
|
129 |
|
130 |
tx.text((1122, 694), BRAND,font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
131 |
|
|
|
134 |
file.seek(0)
|
135 |
return file
|
136 |
|
137 |
+
def reverseMake(name, tag, id, content, icon):
|
138 |
img = BASE_IMAGE.copy()
|
139 |
|
140 |
icon = Image.open(io.BytesIO(requests.get(icon).content))
|
|
|
147 |
|
148 |
tx = ImageDraw.Draw(img)
|
149 |
|
150 |
+
tsize_t = drawText(img, (390, 270), content, size=45, color=(255, 255, 255, 255), split_len=16, auto_expand=True)
|
151 |
|
152 |
name_y = tsize_t[2] + 40
|
153 |
+
tsize_name = drawText(img, (390, name_y), f"{name}#{tag}", size=25, color=(255, 255, 255, 255), split_len=25, disable_dot_wrap=True)
|
154 |
|
155 |
id_y = name_y + tsize_name[1] + 4
|
156 |
+
tsize_id = drawText(img, (390, id_y), id, size=18, color=(180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
|
157 |
|
158 |
tx.text((6, 694), BRAND,font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
159 |
|
|
|
162 |
file.seek(0)
|
163 |
return file
|
164 |
|
165 |
+
def whiteMake(name, tag, id, content, icon):
|
166 |
img = BASE_IMAGE.copy()
|
167 |
|
168 |
icon = Image.open(io.BytesIO(requests.get(icon).content))
|
|
|
175 |
|
176 |
tx = ImageDraw.Draw(img)
|
177 |
|
178 |
+
tsize_t = drawText(img, (890, 270), content, size=45, color=(0, 0, 0, 0), split_len=16, auto_expand=True)
|
179 |
|
180 |
name_y = tsize_t[2] + 40
|
181 |
+
tsize_name = drawText(img, (890, name_y), f"{name}#{tag}", size=25, color=(0, 0, 0, 0), split_len=25, disable_dot_wrap=True)
|
182 |
|
183 |
id_y = name_y + tsize_name[1] + 4
|
184 |
+
tsize_id = drawText(img, (890, id_y), id, size=18, color=(180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
|
185 |
|
186 |
tx.text((1122, 694), BRAND, font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
187 |
|
|
|
193 |
app = Flask(__name__)
|
194 |
|
195 |
@app.route("/", methods=["GET"])
|
196 |
+
def main():
|
197 |
res = make(
|
198 |
request.args.get("name") or "SAMPLE",
|
199 |
request.args.get("tag") or "1234",
|
|
|
205 |
|
206 |
@app.route("/color", methods=["GET"])
|
207 |
def color():
|
208 |
+
res = colorMake(
|
209 |
request.args.get("name") or "SAMPLE",
|
210 |
request.args.get("tag") or "1234",
|
211 |
request.args.get("id") or "0000000000000000000",
|
|
|
216 |
|
217 |
@app.route("/reverse", methods=["GET"])
|
218 |
def reverse():
|
219 |
+
res = reverseMake(
|
220 |
request.args.get("name") or "SAMPLE",
|
221 |
request.args.get("tag") or "1234",
|
222 |
request.args.get("id") or "0000000000000000000",
|
|
|
227 |
|
228 |
@app.route("/white", methods=["GET"])
|
229 |
def white():
|
230 |
+
res = whiteMake(
|
231 |
request.args.get("name") or "SAMPLE",
|
232 |
request.args.get("tag") or "1234",
|
233 |
request.args.get("id") or "0000000000000000000",
|