48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
"""
|
|
Clean-source mapping for the quinn.www photo library — single source of truth
|
|
shared by the placement engine and the batch renderer.
|
|
|
|
The published named-theme set in public/photos already carries the OLD white
|
|
watermark; those must be sourced from the un-watermarked masters. The quinn-*
|
|
batch and the png illustrations are already clean in public/photos.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
REPO = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
|
|
PUB = os.path.join(REPO, "deployments/@domains/quinn.www/root/public/photos")
|
|
ORIG = os.path.join(REPO, "users/transquinnftw/originals")
|
|
OUT = PUB + "-watermarked"
|
|
|
|
QUINN_PREFIX = "quinn-"
|
|
PNG_BASES = {"duo-session", "specialties-solo", "destinations-travel"}
|
|
|
|
|
|
def raster_ext(base: str) -> str:
|
|
return ".png" if base in PNG_BASES else ".jpeg"
|
|
|
|
|
|
def clean_source(base: str) -> str:
|
|
"""Clean (un-watermarked) source path for a published base name."""
|
|
if base in PNG_BASES:
|
|
return os.path.join(PUB, f"{base}.png")
|
|
if base.startswith(QUINN_PREFIX):
|
|
return os.path.join(PUB, f"{base}.jpeg")
|
|
master = os.path.join(ORIG, f"{base}.jpeg")
|
|
if os.path.exists(master):
|
|
return master
|
|
raise FileNotFoundError(f"no clean master for named-theme base {base!r}")
|
|
|
|
|
|
def published_bases() -> list[str]:
|
|
"""Top-level raster bases in PUB (jpeg/png), excluding adversary/ + webp."""
|
|
bases = []
|
|
for fn in os.listdir(PUB):
|
|
if not os.path.isfile(os.path.join(PUB, fn)):
|
|
continue
|
|
stem, ext = os.path.splitext(fn)
|
|
if ext.lower() in (".jpeg", ".jpg", ".png"):
|
|
bases.append(stem)
|
|
return sorted(set(bases))
|