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