From b6f4172514c5705c27bb828d1f46421a026c2632 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Fri, 1 May 2026 22:51:58 +0000 Subject: [PATCH] preview: remove ffprobe fallback and unused json import _get_image_dimensions now relies solely on pyvips header reading. If pyvips cannot read the header the function returns None and the caller encodes at full resolution rather than falling back to ffprobe. Remove unused stdlib json import. --- cista/preview.py | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/cista/preview.py b/cista/preview.py index 4b93e81..abe042c 100644 --- a/cista/preview.py +++ b/cista/preview.py @@ -2,7 +2,6 @@ import asyncio import contextlib import gc import io -import json import mimetypes import struct import subprocess @@ -706,37 +705,13 @@ def _get_image_dimensions(path: Path) -> tuple[int, int] | None: """Probe image dimensions. pyvips can read the header of most formats (including HEIC) without - fully decoding the image. ffprobe is used as a fallback. + fully decoding the image. """ try: img = pyvips.Image.new_from_file(str(path)) return img.width, img.height except pyvips.error.Error: - pass - try: - result = subprocess.run( - [ - "ffprobe", - "-v", - "error", - "-select_streams", - "v:0", - "-show_entries", - "stream=width,height", - "-of", - "csv=s=x:p=0", - str(path), - ], - capture_output=True, - text=True, - check=True, - ) - parts = result.stdout.strip().split("x") - if len(parts) == 2: - return int(parts[0]), int(parts[1]) - except Exception: - pass - return None + return None def _image_via_ffmpeg(path: Path, maxsize: int, quality: int) -> bytes: