feat: unify source libraries, generation plans and terminal bindings
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user