From 2186f500659eda997489834b020c3850156747b2 Mon Sep 17 00:00:00 2001 From: pax Date: Sat, 11 Apr 2026 17:29:04 -0500 Subject: [PATCH] remove dead code: core/images.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make_thumbnail and image_dimensions were both unreferenced. The library's actual thumbnailing happens inline in gui/library.py (PIL for stills, ffmpeg subprocess for videos), and the live image_dimensions used by main_window.py is the static method on gui/media_controller.py — not the standalone function this file exposed. Audit finding #15 follow-up. --- booru_viewer/core/images.py | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 booru_viewer/core/images.py diff --git a/booru_viewer/core/images.py b/booru_viewer/core/images.py deleted file mode 100644 index 3e12175..0000000 --- a/booru_viewer/core/images.py +++ /dev/null @@ -1,31 +0,0 @@ -"""Image thumbnailing and format helpers.""" - -from __future__ import annotations - -from pathlib import Path - -from PIL import Image - -from .config import DEFAULT_THUMBNAIL_SIZE, thumbnails_dir - - -def make_thumbnail( - source: Path, - size: tuple[int, int] = DEFAULT_THUMBNAIL_SIZE, - dest: Path | None = None, -) -> Path: - """Create a thumbnail, returning its path. Returns existing if already made.""" - dest = dest or thumbnails_dir() / f"thumb_{source.stem}_{size[0]}x{size[1]}.jpg" - if dest.exists(): - return dest - with Image.open(source) as img: - img.thumbnail(size, Image.Resampling.LANCZOS) - if img.mode in ("RGBA", "P"): - img = img.convert("RGB") - img.save(dest, "JPEG", quality=85) - return dest - - -def image_dimensions(path: Path) -> tuple[int, int]: - with Image.open(path) as img: - return img.size