diff --git a/croppa/main.py b/croppa/main.py index 2a96d4a..8279840 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -12,6 +12,18 @@ import json import subprocess import queue 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: """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) if self.is_image_mode: - # Load static image - self.static_image = cv2.imread(str(media_path)) - if self.static_image is None: - raise ValueError(f"Could not load image file: {media_path}") + # Load static image with UTF-8 support + self.static_image = load_image_utf8(media_path) # Set up image properties to mimic video interface self.frame_height, self.frame_width = self.static_image.shape[:2] diff --git a/croppa/pyproject.toml b/croppa/pyproject.toml index e2ee53c..e63c721 100644 --- a/croppa/pyproject.toml +++ b/croppa/pyproject.toml @@ -6,7 +6,8 @@ readme = "README.md" requires-python = ">=3.13" dependencies = [ "opencv-python>=4.8.0", - "numpy>=1.24.0" + "numpy>=1.24.0", + "Pillow>=10.0.0" ] [project.scripts]