Add UTF-8 image loading support in VideoEditor and update dependencies

This commit is contained in:
2025-09-26 11:05:14 +02:00
parent bae760837c
commit 5c66935157
2 changed files with 16 additions and 5 deletions

View File

@@ -12,6 +12,18 @@ import json
import subprocess import subprocess
import queue import queue
import ctypes import ctypes
from PIL import Image
def load_image_utf8(image_path):
"""Load image with UTF-8 path support using PIL, then convert to OpenCV format"""
try:
# Use PIL to load image with UTF-8 support
pil_image = Image.open(image_path)
# Convert PIL image to OpenCV format (BGR)
cv_image = cv2.cvtColor(np.array(pil_image), cv2.COLOR_RGB2BGR)
return cv_image
except Exception as e:
raise ValueError(f"Could not load image file: {image_path} - {e}")
class Cv2BufferedCap: class Cv2BufferedCap:
"""Buffered wrapper around cv2.VideoCapture that handles frame loading, seeking, and caching correctly""" """Buffered wrapper around cv2.VideoCapture that handles frame loading, seeking, and caching correctly"""
@@ -849,10 +861,8 @@ class VideoEditor:
self.is_image_mode = self._is_image_file(media_path) self.is_image_mode = self._is_image_file(media_path)
if self.is_image_mode: if self.is_image_mode:
# Load static image # Load static image with UTF-8 support
self.static_image = cv2.imread(str(media_path)) self.static_image = load_image_utf8(media_path)
if self.static_image is None:
raise ValueError(f"Could not load image file: {media_path}")
# Set up image properties to mimic video interface # Set up image properties to mimic video interface
self.frame_height, self.frame_width = self.static_image.shape[:2] self.frame_height, self.frame_width = self.static_image.shape[:2]

View File

@@ -6,7 +6,8 @@ readme = "README.md"
requires-python = ">=3.13" requires-python = ">=3.13"
dependencies = [ dependencies = [
"opencv-python>=4.8.0", "opencv-python>=4.8.0",
"numpy>=1.24.0" "numpy>=1.24.0",
"Pillow>=10.0.0"
] ]
[project.scripts] [project.scripts]