mirror of
https://github.com/hacksider/Deep-Live-Cam.git
synced 2026-09-04 23:06:38 +02:00
fix(webp): address review — drop broken GIF, robust ext check, centralize lists
Review feedback on #1831: - Remove *.gif from the save/output dialog filter (PR had added it there). Verified empirically that cv2.imread/imwrite cannot decode OR encode GIF on OpenCV 4.10 *or* 4.11 (write raises, read returns None), so GIF silently failed on both ends — dropped from every dialog and from has_image_extension. - has_image_extension now uses os.path.splitext so only the true extension counts ('photo.png.bak' / 'clip.webp.mp4' are no longer treated as images). - Centralize the supported-extension set in modules.globals (IMAGE_EXTENSIONS / VIDEO_EXTENSIONS); file_types, all QFileDialog filters and has_image_extension now derive from it instead of hand-copied lists that had already drifted. WEBP itself is unchanged and works (libwebp ships with opencv-python).
This commit is contained in:
+14
-5
@@ -236,6 +236,15 @@ _RECENT_SOURCE_DIR: Optional[str] = None
|
||||
_RECENT_TARGET_DIR: Optional[str] = None
|
||||
_RECENT_OUTPUT_DIR: Optional[str] = None
|
||||
|
||||
# QFileDialog filter strings, built from the canonical extension sets in
|
||||
# globals so every dialog stays in sync (no hand-copied lists to drift).
|
||||
_IMAGE_FILE_FILTER = "Images (" + " ".join(
|
||||
f"*{ext}" for ext in modules.globals.IMAGE_EXTENSIONS
|
||||
) + ")"
|
||||
_MEDIA_FILE_FILTER = "Media (" + " ".join(
|
||||
f"*{ext}" for ext in (*modules.globals.IMAGE_EXTENSIONS, *modules.globals.VIDEO_EXTENSIONS)
|
||||
) + ")"
|
||||
|
||||
|
||||
# ─── image utilities ─────────────────────────────────────────────────────
|
||||
|
||||
@@ -733,7 +742,7 @@ class MainWindow(QMainWindow):
|
||||
path, _filter = QFileDialog.getOpenFileName(
|
||||
self, _("select an source image"),
|
||||
_RECENT_SOURCE_DIR or "",
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp *.webp)",
|
||||
_IMAGE_FILE_FILTER,
|
||||
)
|
||||
if path and is_image(path):
|
||||
modules.globals.source_path = path
|
||||
@@ -754,7 +763,7 @@ class MainWindow(QMainWindow):
|
||||
path, _filter = QFileDialog.getOpenFileName(
|
||||
self, _("select an target image or video"),
|
||||
_RECENT_TARGET_DIR or "",
|
||||
"Media (*.png *.jpg *.jpeg *.gif *.bmp *.webp *.mp4 *.mkv)",
|
||||
_MEDIA_FILE_FILTER,
|
||||
)
|
||||
if not path:
|
||||
return
|
||||
@@ -885,7 +894,7 @@ class MainWindow(QMainWindow):
|
||||
path, _f = QFileDialog.getSaveFileName(
|
||||
self, _("save image output file"),
|
||||
os.path.join(_RECENT_OUTPUT_DIR or "", "output.png"),
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp *.webp)",
|
||||
_IMAGE_FILE_FILTER,
|
||||
)
|
||||
elif is_video(modules.globals.target_path):
|
||||
path, _f = QFileDialog.getSaveFileName(
|
||||
@@ -1333,7 +1342,7 @@ class MapperDialog(QDialog):
|
||||
path, _f = QFileDialog.getOpenFileName(
|
||||
self, _("select an source image"),
|
||||
_RECENT_SOURCE_DIR or "",
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp *.webp)",
|
||||
_IMAGE_FILE_FILTER,
|
||||
)
|
||||
if not path:
|
||||
return
|
||||
@@ -1438,7 +1447,7 @@ class LiveMapperDialog(QDialog):
|
||||
path, _f = QFileDialog.getOpenFileName(
|
||||
self, _("select an source image"),
|
||||
_RECENT_SOURCE_DIR or "",
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp *.webp)",
|
||||
_IMAGE_FILE_FILTER,
|
||||
)
|
||||
if not path:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user