--- gimp-2.99.16/tools/colorsvg2png.c.old 2023-07-06 00:00:47.000000000 +1000 +++ gimp-2.99.16/tools/colorsvg2png.c 2023-12-22 21:40:37.708428011 +1000 @@ -25,12 +25,11 @@ RsvgHandle *handle; cairo_surface_t *surface; cairo_t *cr; - RsvgRectangle target_rect; + RsvgDimensionData original_dim; gchar *input; gchar *output; gint dim; - gint retval = 0; if (argc != 4) { @@ -59,30 +58,28 @@ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dim, dim); cr = cairo_create (surface); + rsvg_handle_get_dimensions (handle, &original_dim); + cairo_surface_destroy (surface); + cairo_scale (cr, + (gdouble) dim / (gdouble) original_dim.width, + (gdouble) dim / (gdouble) original_dim.height); - target_rect.x = target_rect.y = 0; - target_rect.width = target_rect.height = dim; - - if (! rsvg_handle_render_document (handle, cr, &target_rect, NULL)) + if (! rsvg_handle_render_cairo (handle, cr)) { g_fprintf (stderr, "Error: failed to render '%s'\n", input); - retval = 1; + return 1; } - if (retval == 0 && - cairo_surface_write_to_png (surface, output) != CAIRO_STATUS_SUCCESS) + if (cairo_surface_write_to_png (surface, output) != CAIRO_STATUS_SUCCESS) { g_fprintf (stderr, "Error: failed to write '%s'\n", output); - retval = 1; + return 1; } - - cairo_surface_destroy (surface); cairo_destroy (cr); - g_object_unref (handle); - return retval; + return 0; }