From 4c0fc8ecbc17897e988a04bbcef04465aa5439ae Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Fri, 26 Sep 2025 15:10:19 +0200 Subject: [PATCH] Refactor video frame scaling logic in VideoEditor to simplify resizing process This commit removes redundant checks for scaling dimensions and ensures that the video frame is resized correctly while maintaining the aspect ratio. The logic is streamlined to enhance clarity and efficiency in the resizing process, improving overall performance during video editing. --- croppa/main.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/croppa/main.py b/croppa/main.py index aed04eb..7a0062b 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -2907,24 +2907,10 @@ class VideoEditor: scale_y = available_height / height scale = min(scale_x, scale_y) # Use the smaller scale to ensure video fits - # Ensure scale is never greater than 1.0 to prevent upscaling beyond screen - scale = min(scale, 1.0) - # Calculate scaled dimensions scaled_width = int(width * scale) scaled_height = int(height * scale) - # Double-check that scaled dimensions fit within available space - if scaled_height > available_height: - scale = available_height / height - scaled_width = int(width * scale) - scaled_height = int(height * scale) - - if scaled_width > actual_width: - scale = actual_width / width - scaled_width = int(width * scale) - scaled_height = int(height * scale) - # Resize the frame to fit the window while maintaining aspect ratio if scale != 1.0: display_frame = cv2.resize(display_frame, (scaled_width, scaled_height), interpolation=cv2.INTER_LINEAR)