Skip write-only formats (#308)

PALM and PDF are write-only formats by PIL, these cannot be opened.

Also move SVG out from the loop to avoid adding it multiple times.

Reference:
https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#write-only-formats
This commit is contained in:
Balló György
2024-11-04 12:13:17 +01:00
committed by GitHub
parent 965b6d94f2
commit 3e9c947cf0

View File

@@ -89,8 +89,11 @@ class DetailsDialog(Adw.Dialog):
self.apply_button.set_label(_("Add"))
image_filter = Gtk.FileFilter(name=_("Images"))
for extension in Image.registered_extensions():
# .palm and .pdf are write-only
for extension in set(Image.registered_extensions()) - {".palm", ".pdf"}:
image_filter.add_suffix(extension[1:])
image_filter.add_suffix("svg") # Gdk.Texture supports .svg but PIL doesn't
image_filters = Gio.ListStore.new(Gtk.FileFilter)