From 0d1c98837d68ec1dad8bbfadd54055cac8f75a69 Mon Sep 17 00:00:00 2001 From: Hugo Posnic Date: Fri, 3 Nov 2023 08:57:48 +0100 Subject: [PATCH] Fix #189 --- src/tools.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/tools.py b/src/tools.py index 64917f8..dd87ff4 100644 --- a/src/tools.py +++ b/src/tools.py @@ -62,18 +62,15 @@ def add_filechooser_filters(dialog): def get_file_type(filename): - content_type, uncertain = Gio.content_type_guess(filename=str(filename)) - if not uncertain: - if content_type == 'image/jpeg': - return 'jpg' - elif content_type == 'image/png': - return 'png' - elif content_type == 'image/webp': - return 'webp' - elif content_type == 'image/svg+xml': - return 'svg' - else: - return None + content_type = Gio.content_type_guess(filename=str(filename))[0] + if content_type == 'image/jpeg': + return 'jpg' + elif content_type == 'image/png': + return 'png' + elif content_type == 'image/webp': + return 'webp' + elif content_type == 'image/svg+xml': + return 'svg' else: return None