photo_bot: разрешение фото для ИИ 768->1536 (PHOTO_TEST_AI_MAX_SIDE)

This commit is contained in:
Denis Krivochenko
2026-08-17 17:17:02 +07:00
parent 0941a28da4
commit 9271c23780
2 changed files with 7 additions and 3 deletions
+3 -2
View File
@@ -58,10 +58,11 @@ def validate_photo_with_ai(file_bytes: bytes) -> dict:
Возвращает {'ok': bool, 'verdict': str, 'reason': str, 'error': str}
"""
try:
# Сжатие как в photo_validator.py (PIL, без сторонних DLL)
# Сжатие (PIL): разрешение настраивается в config (PHOTO_TEST_AI_MAX_SIDE)
side = int(config.PHOTO_TEST_AI_MAX_SIDE)
with Image.open(io.BytesIO(file_bytes)) as img:
img = img.convert('RGB')
img.thumbnail((768, 768))
img.thumbnail((side, side))
buffer = io.BytesIO()
img.save(buffer, format='JPEG', quality=85)
b64_img = base64.b64encode(buffer.getvalue()).decode('utf-8')