app: fix #7287 failure to save metadata when creating a new image

When starting from an image we created in GIMP, saving/exporting with
metadata and/or thumbnail (thumbnails are part of the exif metadata)
failed, because our metadata was not initialized for newly created
images.

To fix this, create a metadata object in `gimp_create_image`, that way
when creating a new image in the gui, but also when creating an
image programmatically, gets metadata attached at the start.

We need to do that here, because we need to have metadata available
even for images that we import that do not have metadata attached.
This commit is contained in:
Jacob Boerema 2025-01-13 16:15:02 -05:00
parent f373186dfd
commit 4ff4ce2870

View file

@ -63,6 +63,7 @@
#include "gimpgradient.h"
#include "gimpidtable.h"
#include "gimpimage.h"
#include "gimpimage-metadata.h"
#include "gimpimagefile.h"
#include "gimplist.h"
#include "gimpmarshal.h"
@ -1036,12 +1037,17 @@ gimp_create_image (Gimp *gimp,
GimpPrecision precision,
gboolean attach_comment)
{
GimpImage *image;
GimpImage *image;
GimpMetadata *metadata;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
image = gimp_image_new (gimp, width, height, type, precision);
metadata = gimp_metadata_new ();
gimp_image_set_metadata (image, metadata, FALSE);
g_object_unref (metadata);
if (attach_comment)
{
const gchar *comment;