26 lines
722 B
Python
26 lines
722 B
Python
"""Layout-only extension point for a future AI layout provider."""
|
|||
|
|
|
||
|
|
from dataclasses import dataclass
|
||
|
|
from typing import Protocol
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass(frozen=True)
|
||
|
|
class PhotoLayout:
|
||
|
|
footer_height: int
|
||
|
|
font_size: int
|
||
|
|
margin: int
|
||
|
|
|
||
|
|
|
||
|
|
class PhotoLayoutProvider(Protocol):
|
||
|
|
def layout(self, size: tuple[int, int], caption: dict[str, str]) -> PhotoLayout: ...
|
||
|
|
|
||
|
|
|
||
|
|
class WatermarkLayout:
|
||
|
|
def layout(self, size: tuple[int, int], caption: dict[str, str]) -> PhotoLayout:
|
||
|
|
width, height = size
|
||
|
|
return PhotoLayout(
|
||
|
|
footer_height=max(60, round(min(width, height) * 0.06)),
|
||
|
|
font_size=max(24, round(min(width, height) * 0.03)),
|
||
|
|
margin=max(24, round(width * 0.025)),
|
||
|
|
)
|