From 8143bdcb6cdb06c9886cda7f177d8c3066a3391a Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Fri, 12 May 2023 09:48:25 +0100 Subject: [PATCH] Revert "FIXME: this can be rather slow and blocks until the size is known" This reverts commit 8aeeb06fa5ab39f9e58938c2a8af3029fd67cbff. gdk_pixbuf_get_file_info() can only get the file info from file types that it knows. --- src/image-load.cc | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/image-load.cc b/src/image-load.cc index 40d45633..03582d1a 100644 --- a/src/image-load.cc +++ b/src/image-load.cc @@ -1429,27 +1429,32 @@ const gchar *image_loader_get_error(ImageLoader *il) return ret; } + +/** + * @FIXME this can be rather slow and blocks until the size is known + */ gboolean image_load_dimensions(FileData *fd, gint *width, gint *height) { + ImageLoader *il; gboolean success; - gint width_file = 0; - gint height_file = 0; - gdk_pixbuf_get_file_info(fd->path, &width_file, &height_file); + il = image_loader_new(fd); - if (width_file && height_file) + success = image_loader_start_idle(il); + + if (success && il->pixbuf) { - *width = width_file; - *height = height_file; - success = TRUE; + if (width) *width = gdk_pixbuf_get_width(il->pixbuf); + if (height) *height = gdk_pixbuf_get_height(il->pixbuf);; } else { - *width = -1; - *height = -1; - success = FALSE; + if (width) *width = -1; + if (height) *height = -1; } + image_loader_free(il); + return success; } /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ -- 2.20.1