Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
d7afd342 by cal0pteryx at 2026-03-21T12:17:06+01:00
fix: Image preview: Guard for exceptions while determining size/type
Fixes #12672
- - - - -
1 changed file:
- gajim/common/util/image.py
Changes:
=====================================
gajim/common/util/image.py
=====================================
@@ -123,12 +123,22 @@ def scale_with_ratio(size: int, width: int, height: int)
-> tuple[int, int]:
def image_size(image_path: Path) -> tuple[int, int]:
- with Image.open(image_path) as image:
- width, height = image.size
- return width, height
+ try:
+ with Image.open(image_path) as image:
+ width, height = image.size
+ return width, height
+ except Exception:
+ log.warning("Could not determine image size for %s", image_path,
exc_info=True)
+ return 0, 0
def is_image_animated(image_path: Path) -> bool:
- with Image.open(image_path) as image:
- n_frames: int = getattr(image, "n_frames", 1)
- return getattr(image, "is_animated", False) and n_frames > 1
+ try:
+ with Image.open(image_path) as image:
+ n_frames: int = getattr(image, "n_frames", 1)
+ return getattr(image, "is_animated", False) and n_frames > 1
+ except Exception:
+ log.warning(
+ "Could not determine if image is animated: %s", image_path,
exc_info=True
+ )
+ return False
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/d7afd342353aed09202968a07f085af0d52e0775
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/d7afd342353aed09202968a07f085af0d52e0775
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]