init
This commit is contained in:
commit
3d92973fab
8 changed files with 315 additions and 0 deletions
0
lemmyprivacycheck/__init__.py
Normal file
0
lemmyprivacycheck/__init__.py
Normal file
19
lemmyprivacycheck/__main__.py
Normal file
19
lemmyprivacycheck/__main__.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import fastapi
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from io import BytesIO
|
||||
app = fastapi.FastAPI()
|
||||
|
||||
img = Image.open("./smoking-caterpillar.jpg")
|
||||
font = ImageFont.truetype("./unicode.impact.ttf", 72)
|
||||
|
||||
class JPEGResponse(fastapi.Response):
|
||||
media_type="image/jpeg"
|
||||
|
||||
@app.get("/img", response_class=JPEGResponse)
|
||||
async def getImage(request: fastapi.Request):
|
||||
img2 = img.copy()
|
||||
draw = ImageDraw.Draw(img2)
|
||||
draw.text((img2.width/2,img2.height/2), request.client.host, (255,255,255), font=font, stroke_width=5, stroke_fill=(0,0,0), anchor="mm")
|
||||
img_bin = BytesIO()
|
||||
img2.save(img_bin, format="jpeg")
|
||||
return fastapi.Response(content=img_bin.getvalue(), media_type="image/jpeg")
|
BIN
lemmyprivacycheck/smoking-caterpillar.jpg
Normal file
BIN
lemmyprivacycheck/smoking-caterpillar.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
Loading…
Add table
Add a link
Reference in a new issue