gfhfgh
This commit is contained in:
22
get_data.py
22
get_data.py
@@ -1,6 +1,5 @@
|
|||||||
from fastapi import FastAPI, HTTPException, Request
|
from fastapi import FastAPI, HTTPException, Request
|
||||||
from fastapi.responses import Response, HTMLResponse, FileResponse, StreamingResponse
|
from fastapi.responses import Response, HTMLResponse, StreamingResponse
|
||||||
from typing import Dict, Any
|
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
import requests, uvicorn, json
|
import requests, uvicorn, json
|
||||||
import threading, queue
|
import threading, queue
|
||||||
@@ -17,7 +16,6 @@ import io, os, platform, time
|
|||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
import re
|
import re
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
import base64
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
|
||||||
@@ -3433,13 +3431,19 @@ def get_image(points, bib, count_point):
|
|||||||
|
|
||||||
# --- подпись Q{period} по центру ---
|
# --- подпись Q{period} по центру ---
|
||||||
label = f"Q{period}"
|
label = f"Q{period}"
|
||||||
bbox = draw.textbbox((0, 0), label, font=font)
|
# узнаём размер текста (Pillow 10+ — textbbox, старые — textsize)
|
||||||
text_w = bbox[2] - bbox[0]
|
try:
|
||||||
text_h = bbox[3] - bbox[1]
|
bbox = draw.textbbox((0, 0), label, font=font)
|
||||||
|
text_w = bbox[2] - bbox[0]
|
||||||
|
text_h = bbox[3] - bbox[1]
|
||||||
|
except AttributeError:
|
||||||
|
# fallback для старых версий Pillow
|
||||||
|
text_w, text_h = draw.textsize(label, font=font)
|
||||||
|
|
||||||
# центрируем относительно точки (px, py)
|
# центр иконки = центр текста
|
||||||
text_x = px - text_w // 2
|
center_x, center_y = px, py
|
||||||
text_y = py - text_h // 2
|
text_x = center_x - text_w // 2
|
||||||
|
text_y = center_y - text_h // 2
|
||||||
|
|
||||||
# тень
|
# тень
|
||||||
draw.text((text_x + 1, text_y + 1), label, font=font, fill=(0, 0, 0, 255))
|
draw.text((text_x + 1, text_y + 1), label, font=font, fill=(0, 0, 0, 255))
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ python-telegram-handler
|
|||||||
python-dotenv
|
python-dotenv
|
||||||
--extra-index-url https://git.tvstart.ru/api/packages/lexx/pypi/simple
|
--extra-index-url https://git.tvstart.ru/api/packages/lexx/pypi/simple
|
||||||
nasio
|
nasio
|
||||||
pillow>=12.0.0
|
pillow
|
||||||
Reference in New Issue
Block a user