Spaces:
Building
Building
Taka005
commited on
Commit
·
3fffef8
1
Parent(s):
c036669
完成
Browse files- Dockerfile +0 -11
- docker-compose.yml +0 -10
- main.py +15 -25
- requirements.txt +1 -2
Dockerfile
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
FROM python:3
|
2 |
-
|
3 |
-
|
4 |
-
WORKDIR /app
|
5 |
-
|
6 |
-
|
7 |
-
COPY requirements.txt .
|
8 |
-
RUN pip install -r requirements.txt uvicorn[standard]
|
9 |
-
|
10 |
-
COPY . .
|
11 |
-
CMD ["gunicorn", "main:app", "-b", "0.0.0.0:8080", "-k", "uvicorn.workers.UvicornWorker"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docker-compose.yml
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
version: '3'
|
2 |
-
services:
|
3 |
-
python3:
|
4 |
-
restart: always
|
5 |
-
build: .
|
6 |
-
container_name: 'python3'
|
7 |
-
working_dir: '/root/'
|
8 |
-
tty: true
|
9 |
-
volumes:
|
10 |
-
- ./opt:/root/opt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.py
CHANGED
@@ -14,9 +14,9 @@ BASE_GD_IMAGE = Image.open("images/base-gd.png")
|
|
14 |
BASE_FLIPPED_IMAGE = Image.open("images/base-gd-flipped.png")
|
15 |
BASE_IMAGE = Image.open("images/base.png")
|
16 |
MPLUS_FONT = ImageFont.truetype("fonts/MPLUSRounded1c-Regular.ttf", size=16)
|
17 |
-
branding = "TakasumiBOT"
|
18 |
|
19 |
-
|
20 |
draw = ImageDraw.Draw(im)
|
21 |
fontObj = ImageFont.truetype(font, size=size)
|
22 |
|
@@ -97,39 +97,33 @@ def make(name, tag, id, content, icon):
|
|
97 |
id_y = name_y + tsize_name[1] + 4
|
98 |
tsize_id = draw_text(img, (890, id_y), id, size=18, color=(180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
|
99 |
|
100 |
-
tx.text((
|
101 |
-
font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
102 |
|
103 |
file = io.BytesIO()
|
104 |
img.save(file, format="PNG", quality=95)
|
105 |
file.seek(0)
|
106 |
return file
|
107 |
|
108 |
-
def
|
109 |
img = BASE_IMAGE.copy()
|
110 |
|
111 |
icon = Image.open(io.BytesIO(requests.get(icon).content))
|
112 |
icon = icon.resize((720, 720), Image.LANCZOS)
|
113 |
-
icon_filtered = ImageEnhance.Brightness(icon)
|
114 |
|
115 |
-
img.paste(
|
116 |
img.paste(BASE_GD_IMAGE, (0, 0), BASE_GD_IMAGE)
|
117 |
|
118 |
tx = ImageDraw.Draw(img)
|
119 |
|
120 |
-
tsize_t = draw_text(img, (890, 270), content, size=45, color=(
|
121 |
-
255, 255, 255, 255), split_len=16, auto_expand=True)
|
122 |
|
123 |
name_y = tsize_t[2] + 40
|
124 |
-
tsize_name = draw_text(img, (890, name_y), f"{name}#{tag}", size=25, color=(
|
125 |
-
255, 255, 255, 255), split_len=25, disable_dot_wrap=True)
|
126 |
|
127 |
id_y = name_y + tsize_name[1] + 4
|
128 |
-
tsize_id = draw_text(img, (890, id_y), id, size=18, color=(
|
129 |
-
180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
|
130 |
|
131 |
-
tx.text((
|
132 |
-
font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
133 |
|
134 |
file = io.BytesIO()
|
135 |
img.save(file, format="PNG", quality=95)
|
@@ -149,19 +143,15 @@ def reversemake(name, tag, id, content, icon):
|
|
149 |
|
150 |
tx = ImageDraw.Draw(img)
|
151 |
|
152 |
-
tsize_t = draw_text(img, (390, 270), content, size=45, color=(
|
153 |
-
255, 255, 255, 255), split_len=16, auto_expand=True)
|
154 |
|
155 |
name_y = tsize_t[2] + 40
|
156 |
-
tsize_name = draw_text(img, (390, name_y), f"{name}#{tag}", size=25, color=(
|
157 |
-
255, 255, 255, 255), split_len=25, disable_dot_wrap=True)
|
158 |
|
159 |
id_y = name_y + tsize_name[1] + 4
|
160 |
-
tsize_id = draw_text(img, (390, id_y), id, size=18, color=(
|
161 |
-
180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
|
162 |
|
163 |
-
tx.text((
|
164 |
-
font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
165 |
|
166 |
file = io.BytesIO()
|
167 |
img.save(file, format="PNG", quality=95)
|
@@ -182,8 +172,8 @@ def original():
|
|
182 |
return send_file(res, mimetype="image/png")
|
183 |
|
184 |
@app.route("/color", methods=["GET"])
|
185 |
-
def
|
186 |
-
res =
|
187 |
request.args.get("name") or "SAMPLE",
|
188 |
request.args.get("tag") or "1234",
|
189 |
request.args.get("id") or "0000000000000000000",
|
|
|
14 |
BASE_FLIPPED_IMAGE = Image.open("images/base-gd-flipped.png")
|
15 |
BASE_IMAGE = Image.open("images/base.png")
|
16 |
MPLUS_FONT = ImageFont.truetype("fonts/MPLUSRounded1c-Regular.ttf", size=16)
|
17 |
+
branding = "TakasumiBOT#7189"
|
18 |
|
19 |
+
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):
|
20 |
draw = ImageDraw.Draw(im)
|
21 |
fontObj = ImageFont.truetype(font, size=size)
|
22 |
|
|
|
97 |
id_y = name_y + tsize_name[1] + 4
|
98 |
tsize_id = draw_text(img, (890, id_y), id, size=18, color=(180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
|
99 |
|
100 |
+
tx.text((1122, 694), branding, font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
|
|
101 |
|
102 |
file = io.BytesIO()
|
103 |
img.save(file, format="PNG", quality=95)
|
104 |
file.seek(0)
|
105 |
return file
|
106 |
|
107 |
+
def colormake(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 |
|
113 |
+
img.paste(icon, (0, 0))
|
114 |
img.paste(BASE_GD_IMAGE, (0, 0), BASE_GD_IMAGE)
|
115 |
|
116 |
tx = ImageDraw.Draw(img)
|
117 |
|
118 |
+
tsize_t = draw_text(img, (890, 270), content, size=45, color=(255, 255, 255, 255), split_len=16, auto_expand=True)
|
|
|
119 |
|
120 |
name_y = tsize_t[2] + 40
|
121 |
+
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)
|
|
|
122 |
|
123 |
id_y = name_y + tsize_name[1] + 4
|
124 |
+
tsize_id = draw_text(img, (890, id_y), id, size=18, color=(180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
|
|
|
125 |
|
126 |
+
tx.text((1122, 694), branding,font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
|
|
127 |
|
128 |
file = io.BytesIO()
|
129 |
img.save(file, format="PNG", quality=95)
|
|
|
143 |
|
144 |
tx = ImageDraw.Draw(img)
|
145 |
|
146 |
+
tsize_t = draw_text(img, (390, 270), content, size=45, color=(255, 255, 255, 255), split_len=16, auto_expand=True)
|
|
|
147 |
|
148 |
name_y = tsize_t[2] + 40
|
149 |
+
tsize_name = draw_text(img, (390, name_y), f"{name}#{tag}", size=25, color=(255, 255, 255, 255), split_len=25, disable_dot_wrap=True)
|
|
|
150 |
|
151 |
id_y = name_y + tsize_name[1] + 4
|
152 |
+
tsize_id = draw_text(img, (390, id_y), id, size=18, color=(180, 180, 180, 255), split_len=45, disable_dot_wrap=True)
|
|
|
153 |
|
154 |
+
tx.text((8, 694), branding,font=MPLUS_FONT, fill=(120, 120, 120, 255))
|
|
|
155 |
|
156 |
file = io.BytesIO()
|
157 |
img.save(file, format="PNG", quality=95)
|
|
|
172 |
return send_file(res, mimetype="image/png")
|
173 |
|
174 |
@app.route("/color", methods=["GET"])
|
175 |
+
def color():
|
176 |
+
res = colormake(
|
177 |
request.args.get("name") or "SAMPLE",
|
178 |
request.args.get("tag") or "1234",
|
179 |
request.args.get("id") or "0000000000000000000",
|
requirements.txt
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
pillow==9.4.0
|
2 |
pilmoji==2.0.2
|
3 |
flask==2.2.3
|
4 |
-
requests==2.28.2
|
5 |
-
gunicorn==20.1.0
|
|
|
1 |
pillow==9.4.0
|
2 |
pilmoji==2.0.2
|
3 |
flask==2.2.3
|
4 |
+
requests==2.28.2
|
|