feat: add local image enhancement and lossless mod assets
CI / frontend (push) Failing after 26s
CI / backend (push) Failing after 1m37s

This commit is contained in:
mrleo1nid committed 2026-10-25 21:41:45 +03:00
1 parent cc71050362
commit f7f7f5b1b3
29 files changed
+1495 -10

No files matched your search

+16
View File
@@ -75,6 +75,22 @@ def _image(src: Path, tmp: Path) -> tuple[Path, str]:
return out, ".webp"
def lossless_image(src: Path, tmp: Path) -> tuple[Path, str]:
"""Validate a static PNG/WebP and preserve its pixels (and original bytes when possible)."""
with Image.open(src) as img:
if img.format not in ("PNG", "WEBP") or getattr(img, "is_animated", False):
raise ValueError("Нужен статичный PNG или WebP")
img.load() # Decode fully: a file header alone is not validation.
if max(img.size) > WEBP_MAX:
out = tmp.with_suffix(".png")
img.save(out, "PNG")
return out, ".png"
ext = ".png" if img.format == "PNG" else ".webp"
out = tmp.with_suffix(ext)
shutil.copyfile(src, out)
return out, ext
def _ffmpeg(src: Path, out: Path, args: list[str]) -> Path:
proc = subprocess.run(
["ffmpeg", "-nostdin", "-hide_banner", "-loglevel", "error", "-y", "-i", str(src),