Handle more error types when opening/saving images with PIL

Decoding/encoding errors sometimes raise an OSError or ValueError.
This commit is contained in:
Balló György
2024-11-02 15:48:31 +01:00
parent fa86a25870
commit 117055bf64
2 changed files with 2 additions and 2 deletions

View File

@@ -302,7 +302,7 @@ class DetailsDialog(Adw.Dialog):
with Image.open(path) as image:
if getattr(image, "is_animated", False):
new_path = convert_cover(path)
except UnidentifiedImageError:
except (UnidentifiedImageError, OSError, ValueError):
pass
if new_path:

View File

@@ -63,7 +63,7 @@ def convert_cover(
if shared.schema.get_boolean("high-quality-images")
else shared.TIFF_COMPRESSION,
)
except UnidentifiedImageError:
except (UnidentifiedImageError, OSError, ValueError):
try:
Gdk.Texture.new_from_filename(str(cover_path)).save_to_tiff(
tmp_path := Gio.File.new_tmp("XXXXXX.tiff")[0].get_path()