Taka005
commited on
Commit
·
bf8ade6
1
Parent(s):
0c0854d
完成
Browse files- Dockerfile +0 -15
- main.py +8 -18
- requirements.txt +127 -2
Dockerfile
CHANGED
@@ -1,18 +1,3 @@
|
|
1 |
FROM python:3
|
2 |
USER root
|
3 |
-
|
4 |
-
RUN apt-get update
|
5 |
-
RUN apt-get -y install locales && \
|
6 |
-
localedef -f UTF-8 -i ja_JP ja_JP.UTF-8
|
7 |
-
ENV LANG ja_JP.UTF-8
|
8 |
-
ENV LANGUAGE ja_JP:ja
|
9 |
-
ENV LC_ALL ja_JP.UTF-8
|
10 |
-
ENV TZ JST-9
|
11 |
-
ENV TERM xterm
|
12 |
-
|
13 |
-
RUN apt-get install -y vim less
|
14 |
-
RUN pip install --upgrade pip
|
15 |
-
RUN pip install --upgrade setuptools
|
16 |
-
|
17 |
-
RUN pip install -r requirements.txt
|
18 |
CMD ["python3", "main.py"]
|
|
|
1 |
FROM python:3
|
2 |
USER root
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
CMD ["python3", "main.py"]
|
main.py
CHANGED
@@ -7,7 +7,6 @@ import warnings
|
|
7 |
import base64
|
8 |
import io
|
9 |
|
10 |
-
# 警告無効化
|
11 |
warnings.simplefilter("ignore")
|
12 |
|
13 |
BASE_GD_IMAGE = Image.open("images/base-gd.png")
|
@@ -55,7 +54,6 @@ def draw_text(im,ofs,string,font="fonts/MPLUSRounded1c-Regular.ttf",size=16,colo
|
|
55 |
|
56 |
draw_lines = []
|
57 |
|
58 |
-
# 計算
|
59 |
for line in lines:
|
60 |
tsize = fontObj.getsize(line)
|
61 |
|
@@ -67,7 +65,6 @@ def draw_text(im,ofs,string,font="fonts/MPLUSRounded1c-Regular.ttf",size=16,colo
|
|
67 |
ofs_y += t_height + padding
|
68 |
dy += t_height + padding
|
69 |
|
70 |
-
# 描画
|
71 |
adj_y = -30 * (len(draw_lines)-1)
|
72 |
for dl in draw_lines:
|
73 |
with Pilmoji(im) as p:
|
@@ -77,7 +74,7 @@ def draw_text(im,ofs,string,font="fonts/MPLUSRounded1c-Regular.ttf",size=16,colo
|
|
77 |
|
78 |
return (0,dy,real_y)
|
79 |
|
80 |
-
def make(name,id,content,icon):
|
81 |
img = BASE_IMAGE.copy()
|
82 |
|
83 |
icon = Image.open(io.BytesIO(requests.get(icon).content))
|
@@ -86,25 +83,18 @@ def make(name,id,content,icon):
|
|
86 |
icon_filtered = ImageEnhance.Brightness(icon)
|
87 |
|
88 |
img.paste(icon_filtered.enhance(0.7),(0,0))
|
89 |
-
|
90 |
-
# グラデーション描画
|
91 |
img.paste(BASE_GD_IMAGE,(0,0),BASE_GD_IMAGE)
|
92 |
|
93 |
-
# テキスト
|
94 |
tx = ImageDraw.Draw(img)
|
95 |
|
96 |
-
# 文章描画
|
97 |
tsize_t = draw_text(img,(890,270),content,size=45,color=(255,255,255,255),split_len=16,auto_expand=True)
|
98 |
|
99 |
-
# 名前描画
|
100 |
name_y = tsize_t[2] + 40
|
101 |
-
tsize_name = draw_text(img,(890,name_y),name,size=25,color=(255,255,255,255),split_len=25,disable_dot_wrap=True)
|
102 |
|
103 |
-
# ID描画
|
104 |
id_y = name_y + tsize_name[1] + 4
|
105 |
tsize_id = draw_text(img,(890,id_y),id,size=18,color=(180,180,180,255),split_len=45,disable_dot_wrap=True)
|
106 |
|
107 |
-
# TakasumiBOT描画
|
108 |
tx.text((1125, 694),"TakasumiBOT#7189",font=MPLUS_FONT,fill=(120,120,120,255))
|
109 |
|
110 |
file = io.BytesIO()
|
@@ -112,16 +102,16 @@ def make(name,id,content,icon):
|
|
112 |
file.seek(0)
|
113 |
return file
|
114 |
|
115 |
-
# APiサーバー
|
116 |
app = Flask(__name__)
|
117 |
@app.route("/",methods=["GET"])
|
118 |
def main():
|
119 |
res = make(
|
120 |
-
request.args.get("name"
|
121 |
-
request.args.get("
|
122 |
-
request.args.get("
|
123 |
-
request.args.get("
|
|
|
124 |
)
|
125 |
return send_file(res,mimetype="image/png")
|
126 |
-
|
127 |
app.run(host="0.0.0.0",port=3000)
|
|
|
7 |
import base64
|
8 |
import io
|
9 |
|
|
|
10 |
warnings.simplefilter("ignore")
|
11 |
|
12 |
BASE_GD_IMAGE = Image.open("images/base-gd.png")
|
|
|
54 |
|
55 |
draw_lines = []
|
56 |
|
|
|
57 |
for line in lines:
|
58 |
tsize = fontObj.getsize(line)
|
59 |
|
|
|
65 |
ofs_y += t_height + padding
|
66 |
dy += t_height + padding
|
67 |
|
|
|
68 |
adj_y = -30 * (len(draw_lines)-1)
|
69 |
for dl in draw_lines:
|
70 |
with Pilmoji(im) as p:
|
|
|
74 |
|
75 |
return (0,dy,real_y)
|
76 |
|
77 |
+
def make(name,tag,id,content,icon):
|
78 |
img = BASE_IMAGE.copy()
|
79 |
|
80 |
icon = Image.open(io.BytesIO(requests.get(icon).content))
|
|
|
83 |
icon_filtered = ImageEnhance.Brightness(icon)
|
84 |
|
85 |
img.paste(icon_filtered.enhance(0.7),(0,0))
|
|
|
|
|
86 |
img.paste(BASE_GD_IMAGE,(0,0),BASE_GD_IMAGE)
|
87 |
|
|
|
88 |
tx = ImageDraw.Draw(img)
|
89 |
|
|
|
90 |
tsize_t = draw_text(img,(890,270),content,size=45,color=(255,255,255,255),split_len=16,auto_expand=True)
|
91 |
|
|
|
92 |
name_y = tsize_t[2] + 40
|
93 |
+
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)
|
94 |
|
|
|
95 |
id_y = name_y + tsize_name[1] + 4
|
96 |
tsize_id = draw_text(img,(890,id_y),id,size=18,color=(180,180,180,255),split_len=45,disable_dot_wrap=True)
|
97 |
|
|
|
98 |
tx.text((1125, 694),"TakasumiBOT#7189",font=MPLUS_FONT,fill=(120,120,120,255))
|
99 |
|
100 |
file = io.BytesIO()
|
|
|
102 |
file.seek(0)
|
103 |
return file
|
104 |
|
|
|
105 |
app = Flask(__name__)
|
106 |
@app.route("/",methods=["GET"])
|
107 |
def main():
|
108 |
res = make(
|
109 |
+
request.args.get("name") or "名無し",
|
110 |
+
request.args.get("tag") or "0000",
|
111 |
+
request.args.get("id") or "0000000000000000000",
|
112 |
+
request.args.get("content") or "これはテストです",
|
113 |
+
request.args.get("icon") or "https://cdn.discordapp.com/embed/avatars/0.png"
|
114 |
)
|
115 |
return send_file(res,mimetype="image/png")
|
116 |
+
|
117 |
app.run(host="0.0.0.0",port=3000)
|
requirements.txt
CHANGED
@@ -1,4 +1,129 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
pilmoji==2.0.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
textwrap3==0.9.2
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiofiles==22.1.0
|
2 |
+
aiosqlite==0.18.0
|
3 |
+
anyio==3.6.2
|
4 |
+
argon2-cffi==21.3.0
|
5 |
+
argon2-cffi-bindings==21.2.0
|
6 |
+
arrow==1.2.3
|
7 |
+
asttokens==2.2.1
|
8 |
+
attrs==22.2.0
|
9 |
+
Babel==2.11.0
|
10 |
+
backcall==0.2.0
|
11 |
+
beautifulsoup4==4.11.2
|
12 |
+
bleach==6.0.0
|
13 |
+
certifi==2022.12.7
|
14 |
+
cffi==1.15.1
|
15 |
+
charset-normalizer==3.0.1
|
16 |
+
click==8.1.3
|
17 |
+
colorama==0.4.6
|
18 |
+
comm==0.1.2
|
19 |
+
contourpy==1.0.7
|
20 |
+
cycler==0.11.0
|
21 |
+
debugpy==1.6.6
|
22 |
+
decorator==5.1.1
|
23 |
+
defusedxml==0.7.1
|
24 |
+
emoji==2.2.0
|
25 |
+
executing==1.2.0
|
26 |
+
fastjsonschema==2.16.2
|
27 |
+
Flask==2.2.3
|
28 |
+
fonttools==4.38.0
|
29 |
+
fqdn==1.5.1
|
30 |
+
gitdb==4.0.10
|
31 |
+
GitPython==3.1.30
|
32 |
+
idna==3.4
|
33 |
+
ipykernel==6.21.2
|
34 |
+
ipython==8.10.0
|
35 |
+
ipython-genutils==0.2.0
|
36 |
+
isoduration==20.11.0
|
37 |
+
itsdangerous==2.1.2
|
38 |
+
jedi==0.18.2
|
39 |
+
Jinja2==3.1.2
|
40 |
+
joblib==1.2.0
|
41 |
+
json5==0.9.11
|
42 |
+
jsonpointer==2.3
|
43 |
+
jsonschema==4.17.3
|
44 |
+
jupyter-events==0.5.0
|
45 |
+
jupyter-server-mathjax==0.2.6
|
46 |
+
jupyter-ydoc==0.2.2
|
47 |
+
jupyter_client==8.0.2
|
48 |
+
jupyter_core==5.2.0
|
49 |
+
jupyter_server==2.3.0
|
50 |
+
jupyter_server_fileid==0.6.0
|
51 |
+
jupyter_server_terminals==0.4.4
|
52 |
+
jupyter_server_ydoc==0.6.1
|
53 |
+
jupyterlab==3.6.1
|
54 |
+
jupyterlab-git==0.41.0
|
55 |
+
jupyterlab-pygments==0.2.2
|
56 |
+
jupyterlab_server==2.19.0
|
57 |
+
kiwisolver==1.4.4
|
58 |
+
MarkupSafe==2.1.2
|
59 |
+
matplotlib==3.7.0
|
60 |
+
matplotlib-inline==0.1.6
|
61 |
+
mistune==2.0.5
|
62 |
+
nbclassic==0.5.1
|
63 |
+
nbclient==0.7.2
|
64 |
+
nbconvert==7.2.9
|
65 |
+
nbdime==3.1.1
|
66 |
+
nbformat==5.7.3
|
67 |
+
nest-asyncio==1.5.6
|
68 |
+
notebook==6.5.2
|
69 |
+
notebook_shim==0.2.2
|
70 |
+
numpy==1.24.2
|
71 |
+
nvidia-cublas-cu11==11.10.3.66
|
72 |
+
nvidia-cuda-nvrtc-cu11==11.7.99
|
73 |
+
nvidia-cuda-runtime-cu11==11.7.99
|
74 |
+
nvidia-cudnn-cu11==8.5.0.96
|
75 |
+
packaging==23.0
|
76 |
+
pandas==1.5.3
|
77 |
+
pandocfilters==1.5.0
|
78 |
+
parso==0.8.3
|
79 |
+
pexpect==4.8.0
|
80 |
+
pickleshare==0.7.5
|
81 |
+
Pillow==9.4.0
|
82 |
pilmoji==2.0.2
|
83 |
+
platformdirs==3.0.0
|
84 |
+
plotly==5.13.0
|
85 |
+
prometheus-client==0.16.0
|
86 |
+
prompt-toolkit==3.0.36
|
87 |
+
psutil==5.9.4
|
88 |
+
ptyprocess==0.7.0
|
89 |
+
pure-eval==0.2.2
|
90 |
+
pycparser==2.21
|
91 |
+
Pygments==2.14.0
|
92 |
+
pyparsing==3.0.9
|
93 |
+
pyrsistent==0.19.3
|
94 |
+
python-dateutil==2.8.2
|
95 |
+
python-json-logger==2.0.6
|
96 |
+
pytz==2022.7.1
|
97 |
+
PyYAML==6.0
|
98 |
+
pyzmq==25.0.0
|
99 |
+
requests==2.28.2
|
100 |
+
rfc3339-validator==0.1.4
|
101 |
+
rfc3986-validator==0.1.1
|
102 |
+
scikit-learn==1.2.1
|
103 |
+
scipy==1.10.0
|
104 |
+
seaborn==0.12.2
|
105 |
+
Send2Trash==1.8.0
|
106 |
+
six==1.16.0
|
107 |
+
smmap==5.0.0
|
108 |
+
sniffio==1.3.0
|
109 |
+
soupsieve==2.4
|
110 |
+
stack-data==0.6.2
|
111 |
+
tenacity==8.2.1
|
112 |
+
terminado==0.17.1
|
113 |
textwrap3==0.9.2
|
114 |
+
threadpoolctl==3.1.0
|
115 |
+
tinycss2==1.2.1
|
116 |
+
tomli==2.0.1
|
117 |
+
torch==1.13.1
|
118 |
+
tornado==6.2
|
119 |
+
traitlets==5.9.0
|
120 |
+
typing_extensions==4.5.0
|
121 |
+
uri-template==1.2.0
|
122 |
+
urllib3==1.26.14
|
123 |
+
wcwidth==0.2.6
|
124 |
+
webcolors==1.12
|
125 |
+
webencodings==0.5.1
|
126 |
+
websocket-client==1.5.1
|
127 |
+
Werkzeug==2.2.3
|
128 |
+
y-py==0.5.5
|
129 |
+
ypy-websocket==0.8.2
|