Skip to content

Commit

Permalink
Fixing regression around thumbnails for image sequences and missing f…
Browse files Browse the repository at this point in the history
…iles. Adding a new "NotFound" thumbnail image as a placeholder.
  • Loading branch information
jonoomph committed Jun 24, 2024
1 parent 4d255d2 commit d268644
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 8 deletions.
15 changes: 10 additions & 5 deletions src/classes/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import openshot
import socket
import time
import shutil
from requests import get
from threading import Thread
from classes import info
Expand Down Expand Up @@ -74,13 +75,17 @@ def GetThumbPath(file_id, thumbnail_frame, clear_cache=False):

def GenerateThumbnail(file_path, thumb_path, thumbnail_frame, width, height, mask, overlay):
"""Create thumbnail image, and check for rotate metadata (if any)"""
if not os.path.exists(file_path):
log.warning(f"Cannot generate thumbnail for missing file: {file_path}")
# Create a clip object and get the reader
try:
clip = openshot.Clip(file_path)
reader = clip.Reader()
except RuntimeError as ex:
# Any failure calling Reader (i.e. file missing or corrupt) use placeholder thumbnail
not_found_path = os.path.join(info.IMAGES_PATH, "NotFound@2x.png")
shutil.copyfile(not_found_path, thumb_path)
log.warning(f"Failed to generate thumbnail for missing file: {file_path}")
return

# Create a clip object and get the reader
clip = openshot.Clip(file_path)
reader = clip.Reader()
scale = get_app().devicePixelRatio()

if scale > 1.0:
Expand Down
Binary file added src/images/NotFound.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
135 changes: 135 additions & 0 deletions src/images/NotFound.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/NotFound@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions src/windows/preview_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,6 @@ def LoadFile(self, path=None):
# Check to see if this path is already loaded
if path == self.clip_path or (not path and not self.clip_path):
return
if path and not os.path.exists(path):
log.warning(f"Cannot load missing file for preview: {path}")
return

log.info("LoadFile %s" % path)

Expand Down

0 comments on commit d268644

Please sign in to comment.