FastAPI service wrapping the Surya-OCR-2 model (datalab-to) served through vLLM: legacy /v1/api/ai/* endpoints, an OpenAI-compatible /v1/chat/completions endpoint, a coalescing request batcher, a local OCR CLI, Docker packaging, multilingual example outputs, and quantization/concurrency benchmarks. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9 lines
233 B
Python
9 lines
233 B
Python
from PIL import Image, ImageDraw
|
|
|
|
|
|
def get_text_size(text, font):
|
|
im = Image.new(mode="P", size=(0, 0))
|
|
draw = ImageDraw.Draw(im)
|
|
_, _, width, height = draw.textbbox((0, 0), text=text, font=font)
|
|
return width, height
|