feat: unify source libraries, generation plans and terminal bindings
Community checks / verify (push) Skipped
Verify Frame Flow / verify (push) Failing after 6m24s

This commit is contained in:
渡口浪人
2026-10-23 17:45:30 +08:00
parent 081d8b6ee0
commit 6277c9d563
25 changed files with 5731 additions and 45 deletions
+7 -2
View File
@@ -17,6 +17,9 @@ def render_captioned_photo(
*,
size=(1200, 1600),
layout_provider=None,
centering=(0.5, 0.5),
quality=93,
respect_fit=False,
):
width, height = size
layout = (layout_provider or WatermarkLayout()).layout(size, caption)
@@ -31,9 +34,11 @@ def render_captioned_photo(
# keeping aspect ratio and cropping rather than stretching or letterboxing.
photo_data = convert(
data,
"smart" if fit == "smart" else "cover",
fit if respect_fit else ("smart" if fit == "smart" else "cover"),
profile,
size=(width, photo_height),
centering=centering,
quality=quality,
)
canvas = Image.new("RGB", size, "white")
with Image.open(BytesIO(photo_data)) as photo:
@@ -64,5 +69,5 @@ def render_captioned_photo(
anchor="rm",
)
out = BytesIO()
canvas.save(out, "JPEG", quality=93, optimize=True)
canvas.save(out, "JPEG", quality=quality, optimize=True)
return out.getvalue()