From 8aeeb06fa5ab39f9e58938c2a8af3029fd67cbff Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Thu, 8 Dec 2022 15:59:27 +0000 Subject: [PATCH] FIXME: this can be rather slow and blocks until the size is known Instead of using image_loader() use gdk_pixbuf_get_file_info() to get image size - this function reads only a small part of the file. --- src/image-load.cc | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/image-load.cc b/src/image-load.cc index fd75cc86..8516ef28 100644 --- a/src/image-load.cc +++ b/src/image-load.cc @@ -1438,32 +1438,27 @@ 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; - il = image_loader_new(fd); + gdk_pixbuf_get_file_info(fd->path, &width_file, &height_file); - success = image_loader_start_idle(il); - - if (success && il->pixbuf) + if (width_file && height_file) { - if (width) *width = gdk_pixbuf_get_width(il->pixbuf); - if (height) *height = gdk_pixbuf_get_height(il->pixbuf);; + *width = width_file; + *height = height_file; + success = TRUE; } else { - if (width) *width = -1; - if (height) *height = -1; + *width = -1; + *height = -1; + success = FALSE; } - image_loader_free(il); - return success; } /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ -- 2.20.1