mirror of
https://github.com/hacksider/Deep-Live-Cam.git
synced 2026-09-01 21:40:52 +02:00
feat: webp source image support
Ported from April 2026 Fork: - has_image_extension() now recognizes .webp/.gif/.bmp - is_image() checks extension before mimetypes (Windows mimetypes doesn't always register webp) - File dialog filter includes *.webp
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
WORKFLOW_DIR = os.path.join(ROOT_DIR, "workflow")
|
||||
|
||||
file_types = [
|
||||
("Image", ("*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp")),
|
||||
("Image", ("*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp", "*.webp")),
|
||||
("Video", ("*.mp4", "*.mkv")),
|
||||
]
|
||||
|
||||
|
||||
+5
-5
@@ -733,7 +733,7 @@ class MainWindow(QMainWindow):
|
||||
path, _filter = QFileDialog.getOpenFileName(
|
||||
self, _("select an source image"),
|
||||
_RECENT_SOURCE_DIR or "",
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp)",
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp *.webp)",
|
||||
)
|
||||
if path and is_image(path):
|
||||
modules.globals.source_path = path
|
||||
@@ -754,7 +754,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 *.mp4 *.mkv)",
|
||||
"Media (*.png *.jpg *.jpeg *.gif *.bmp *.webp *.mp4 *.mkv)",
|
||||
)
|
||||
if not path:
|
||||
return
|
||||
@@ -885,7 +885,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 *.bmp)",
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp *.webp)",
|
||||
)
|
||||
elif is_video(modules.globals.target_path):
|
||||
path, _f = QFileDialog.getSaveFileName(
|
||||
@@ -1333,7 +1333,7 @@ class MapperDialog(QDialog):
|
||||
path, _f = QFileDialog.getOpenFileName(
|
||||
self, _("select an source image"),
|
||||
_RECENT_SOURCE_DIR or "",
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp)",
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp *.webp)",
|
||||
)
|
||||
if not path:
|
||||
return
|
||||
@@ -1438,7 +1438,7 @@ class LiveMapperDialog(QDialog):
|
||||
path, _f = QFileDialog.getOpenFileName(
|
||||
self, _("select an source image"),
|
||||
_RECENT_SOURCE_DIR or "",
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp)",
|
||||
"Images (*.png *.jpg *.jpeg *.gif *.bmp *.webp)",
|
||||
)
|
||||
if not path:
|
||||
return
|
||||
|
||||
@@ -262,11 +262,14 @@ def clean_temp(target_path: str) -> None:
|
||||
|
||||
|
||||
def has_image_extension(image_path: str) -> bool:
|
||||
return image_path.lower().endswith(("png", "jpg", "jpeg"))
|
||||
return image_path.lower().endswith(("png", "jpg", "jpeg", "gif", "bmp", "webp"))
|
||||
|
||||
|
||||
def is_image(image_path: str) -> bool:
|
||||
if image_path and os.path.isfile(image_path):
|
||||
# Extension check first — Windows mimetypes doesn't always register webp
|
||||
if has_image_extension(image_path):
|
||||
return True
|
||||
mimetype, _ = mimetypes.guess_type(image_path)
|
||||
return bool(mimetype and mimetype.startswith("image/"))
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user