Performance: GZip, Cache-Control, WebP, SQLite-Tuning, Indizes, srcset — SW by-v438, APP_VER 417
This commit is contained in:
parent
5bd07d9598
commit
e0c2b2bdc1
10 changed files with 46 additions and 12 deletions
|
|
@ -162,7 +162,7 @@ _PREVIEW_MAX = 800 # längste Seite in Pixeln
|
|||
|
||||
|
||||
def generate_preview(data: bytes, ext: str) -> bytes | None:
|
||||
"""Erzeugt ein JPEG-Preview (max _PREVIEW_MAX px). Gibt None zurück bei Videos/PDFs/Fehler."""
|
||||
"""Erzeugt ein WebP-Preview (max _PREVIEW_MAX px). Gibt None zurück bei Videos/PDFs/Fehler."""
|
||||
if ext.lower() not in _PREVIEW_EXTS:
|
||||
return None
|
||||
try:
|
||||
|
|
@ -172,7 +172,7 @@ def generate_preview(data: bytes, ext: str) -> bytes | None:
|
|||
img = img.convert("RGB")
|
||||
img.thumbnail((_PREVIEW_MAX, _PREVIEW_MAX), Image.LANCZOS)
|
||||
buf = io.BytesIO()
|
||||
img.save(buf, format="JPEG", quality=72, optimize=True)
|
||||
img.save(buf, format="WEBP", quality=80)
|
||||
return buf.getvalue()
|
||||
except Exception:
|
||||
return None
|
||||
|
|
@ -185,11 +185,11 @@ def preview_url_from(url: str | None) -> str | None:
|
|||
return None
|
||||
low = url.lower()
|
||||
if any(low.endswith(s) for s in (
|
||||
".mp4", ".webm", ".mov", ".avi", ".pdf", "_thumb.jpg", "_preview.jpg"
|
||||
".mp4", ".webm", ".mov", ".avi", ".pdf", "_thumb.jpg", "_preview.jpg", "_preview.webp"
|
||||
)):
|
||||
return None
|
||||
base, _ = os.path.splitext(url)
|
||||
return base + "_preview.jpg"
|
||||
return base + "_preview.webp"
|
||||
|
||||
|
||||
def extract_video_thumb(video_path: str) -> str | None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue