diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-11-10 01:03:37 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-11-10 01:04:00 +0100 |
commit | ffda836a15c158872a15ec3c05a139e56c08f46d (patch) | |
tree | 33712605b3e9fdf3f66b3c10338f69504c44470b | |
parent | 7ef4a06defdd57956655c6e5145bb46faddf8a96 (diff) | |
download | fiv-ffda836a15c158872a15ec3c05a139e56c08f46d.tar.gz fiv-ffda836a15c158872a15ec3c05a139e56c08f46d.tar.xz fiv-ffda836a15c158872a15ec3c05a139e56c08f46d.zip |
Also render SVGs with unspecified dimensions
-rw-r--r-- | fastiv-io.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/fastiv-io.c b/fastiv-io.c index 172bddb..66b7010 100644 --- a/fastiv-io.c +++ b/fastiv-io.c @@ -416,9 +416,18 @@ open_librsvg(const gchar *data, gsize len, const gchar *path, GError **error) double w = 0, h = 0; if (!rsvg_handle_get_intrinsic_size_in_pixels(handle, &w, &h)) { - set_error(error, "cannot compute pixel dimensions"); - g_object_unref(handle); - return NULL; + RsvgRectangle viewbox = {}; + gboolean has_viewport = FALSE; + rsvg_handle_get_intrinsic_dimensions(handle, NULL, NULL, NULL, NULL, + &has_viewport, &viewbox); + if (!has_viewport) { + set_error(error, "cannot compute pixel dimensions"); + g_object_unref(handle); + return NULL; + } + + w = viewbox.width; + h = viewbox.height; } cairo_rectangle_t extents = { @@ -526,14 +535,20 @@ fastiv_io_open_from_data(const char *data, size_t len, const gchar *path, // TODO(p): We should try to pass actual processing errors through, // notably only continue with LIBRAW_FILE_UNSUPPORTED. - g_clear_error(error); + if (error) { + g_debug("%s", (*error)->message); + g_clear_error(error); + } #endif // HAVE_LIBRAW --------------------------------------------------------- #ifdef HAVE_LIBRSVG // -------------------------------------------------------- if ((surface = open_librsvg(data, len, path, error))) break; // XXX: It doesn't look like librsvg can return sensible errors. - g_clear_error(error); + if (error) { + g_debug("%s", (*error)->message); + g_clear_error(error); + } #endif // HAVE_LIBRSVG -------------------------------------------------------- // TODO(p): Integrate gdk-pixbuf as a fallback (optional dependency). |