From 3627b5a9c16b76f348bcff85b024f30c2a020118 Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:57:31 -0800 Subject: [PATCH 1/2] bump pyside version to 6.8.0.1 --- requirements.txt | 6 +++--- tagstudio/src/qt/widgets/thumb_renderer.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index cd0ddcb45..9af18fd4b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,9 +9,9 @@ pillow-heif==0.16.0 pillow-jxl-plugin==1.3.0 Pillow==10.3.0 pydub==0.25.1 -PySide6_Addons==6.7.1 -PySide6_Essentials==6.7.1 -PySide6==6.7.1 +PySide6_Addons==6.8.0.1 +PySide6_Essentials==6.8.0.1 +PySide6==6.8.0.1 rawpy==0.21.0 SQLAlchemy==2.0.34 structlog==24.4.0 diff --git a/tagstudio/src/qt/widgets/thumb_renderer.py b/tagstudio/src/qt/widgets/thumb_renderer.py index f78724ae9..ac0abb962 100644 --- a/tagstudio/src/qt/widgets/thumb_renderer.py +++ b/tagstudio/src/qt/widgets/thumb_renderer.py @@ -812,8 +812,8 @@ def _image_vector_thumb(cls, filepath: Path, size: int) -> Image.Image: """ im: Image.Image = None # Create an image to draw the svg to and a painter to do the drawing - image: QImage = QImage(size, size, QImage.Format.Format_ARGB32) - image.fill("#1e1e1e") + q_image: QImage = QImage(size, size, QImage.Format.Format_ARGB32) + q_image.fill("#1e1e1e") # Create an svg renderer, then render to the painter svg: QSvgRenderer = QSvgRenderer(str(filepath)) @@ -821,7 +821,7 @@ def _image_vector_thumb(cls, filepath: Path, size: int) -> Image.Image: if not svg.isValid(): raise UnidentifiedImageError - painter: QPainter = QPainter(image) + painter: QPainter = QPainter(q_image) svg.setAspectRatioMode(Qt.AspectRatioMode.KeepAspectRatio) svg.render(painter) painter.end() @@ -829,7 +829,7 @@ def _image_vector_thumb(cls, filepath: Path, size: int) -> Image.Image: # Write the image to a buffer as png buffer: QBuffer = QBuffer() buffer.open(QBuffer.OpenModeFlag.ReadWrite) - image.save(buffer, "PNG") + q_image.save(buffer, "PNG") # type: ignore[call-overload] # Load the image from the buffer im = Image.new("RGB", (size, size), color="#1e1e1e") @@ -907,11 +907,11 @@ def _pdf_thumb(cls, filepath: Path, size: int) -> Image.Image: | QPdfDocumentRenderOptions.RenderFlag.PathAliased ) # Convert QImage to PIL Image - qimage: QImage = document.render(0, page_size.toSize(), render_options) + q_image: QImage = document.render(0, page_size.toSize(), render_options) buffer: QBuffer = QBuffer() buffer.open(QBuffer.OpenModeFlag.ReadWrite) try: - qimage.save(buffer, "PNG") + q_image.save(buffer, "PNG") # type: ignore[call-overload] im = Image.open(BytesIO(buffer.buffer().data())) finally: buffer.close() From 35f32fe4afaa1e1084769f3a76ea117f8cbc6e2b Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Wed, 4 Dec 2024 17:03:19 -0800 Subject: [PATCH 2/2] fix: try for absolute ffprobe path on macos --- tagstudio/src/qt/helpers/vendored/ffmpeg.py | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tagstudio/src/qt/helpers/vendored/ffmpeg.py b/tagstudio/src/qt/helpers/vendored/ffmpeg.py index 097e78a22..05e1d2586 100644 --- a/tagstudio/src/qt/helpers/vendored/ffmpeg.py +++ b/tagstudio/src/qt/helpers/vendored/ffmpeg.py @@ -3,13 +3,34 @@ # Vendored from ffmpeg-python and ffmpeg-python PR#790 by amamic1803 import json +import platform +import shutil import subprocess import ffmpeg +import structlog from src.qt.helpers.silent_popen import promptless_Popen +logger = structlog.get_logger(__name__) -def _probe(filename, cmd="ffprobe", timeout=None, **kwargs): +FFMPEG_MACOS_LOCATIONS: list[str] = ["", "/opt/homebrew/bin/", "/usr/local/bin/"] + + +def _get_ffprobe_location() -> str: + cmd: str = "ffprobe" + if platform.system() == "Darwin": + for loc in FFMPEG_MACOS_LOCATIONS: + if shutil.which(loc + cmd): + cmd = loc + cmd + break + logger.info(f"[FFPROBE] Using FFmpeg location: {cmd}") + return cmd + + +FFPROBE_CMD = _get_ffprobe_location() + + +def _probe(filename, cmd=FFPROBE_CMD, timeout=None, **kwargs): """Run ffprobe on the specified file and return a JSON representation of the output. Raises: