Integrate the logic of profile saving with metadata saving

Add flag GIMP_METADATA_SAVE_COLOR_PROFILE to GimpMetadataSaveFlags and
initialize it from gimp_export_color_profile() in
gimp_image_metadata_save_prepare().

Adapt all plug-ins to use the bit from the suggested export flags and
pass the actually used value back to
gimp_image_metadata_save_finish().

This changes no behavior at all but creates hooks on the libgimp side
that are called with the context of an image before and after the
actual export, which might become useful later. Also, consistency
is good even though the color profile is not strictly "metadata".
This commit is contained in:
Michael Natterer 2018-12-04 17:28:24 +01:00
parent 7f9379cb32
commit c667fdc5c0
5 changed files with 48 additions and 16 deletions

View File

@ -364,11 +364,17 @@ gimp_image_metadata_save_prepare (gint32 image_ID,
g_date_time_unref (datetime);
}
/* Thumbnail */
if (FALSE /* FIXME if (original image had a thumbnail) */)
*suggested_flags &= ~GIMP_METADATA_SAVE_THUMBNAIL;
}
/* Color profile */
if (! gimp_export_color_profile ())
*suggested_flags &= ~GIMP_METADATA_SAVE_COLOR_PROFILE;
return metadata;
}
@ -620,6 +626,14 @@ gimp_image_metadata_save_finish (gint32 image_ID,
g_object_unref (thumb_pixbuf);
}
if (flags & GIMP_METADATA_SAVE_COLOR_PROFILE)
{
/* nothing to do, but if we ever need to modify metadata based
* on the exported color profile, this is probably the place to
* add it
*/
}
success = gimp_metadata_save_to_file (new_metadata, file, error);
g_object_unref (new_metadata);

View File

@ -59,6 +59,8 @@ typedef enum
* @GIMP_METADATA_SAVE_XMP: Save XMP
* @GIMP_METADATA_SAVE_IPTC: Save IPTC
* @GIMP_METADATA_SAVE_THUMBNAIL: Save a thumbnail of the image
* @GIMP_METADATA_SAVE_COLOR_PROFILE: Save the image's color profile
* Since: 2.10.10
* @GIMP_METADATA_SAVE_ALL: Save all of the above
*
* What kinds of metadata to save when exporting images.
@ -69,6 +71,7 @@ typedef enum
GIMP_METADATA_SAVE_XMP = 1 << 1,
GIMP_METADATA_SAVE_IPTC = 1 << 2,
GIMP_METADATA_SAVE_THUMBNAIL = 1 << 3,
GIMP_METADATA_SAVE_COLOR_PROFILE = 1 << 4,
GIMP_METADATA_SAVE_ALL = 0xffffffff
} GimpMetadataSaveFlags;

View File

@ -553,7 +553,7 @@ run (const gchar *name,
pngvals.save_xmp = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
pngvals.save_iptc = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
pngvals.save_thumbnail = (metadata_flags & GIMP_METADATA_SAVE_THUMBNAIL) != 0;
pngvals.save_profile = gimp_export_color_profile ();
pngvals.save_profile = (metadata_flags & GIMP_METADATA_SAVE_COLOR_PROFILE) != 0;
/* Override preferences from PNG export defaults (if saved). */
load_parasite ();
@ -659,6 +659,11 @@ run (const gchar *name,
else
metadata_flags &= ~GIMP_METADATA_SAVE_THUMBNAIL;
if (pngvals.save_profile)
metadata_flags |= GIMP_METADATA_SAVE_COLOR_PROFILE;
else
metadata_flags &= ~GIMP_METADATA_SAVE_COLOR_PROFILE;
file = g_file_new_for_path (param[3].data.d_string);
gimp_image_metadata_save_finish (orig_image_ID,
"image/png",

View File

@ -347,7 +347,7 @@ run (const gchar *name,
jsvals.save_xmp = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
jsvals.save_iptc = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
jsvals.save_thumbnail = (metadata_flags & GIMP_METADATA_SAVE_THUMBNAIL) != 0;
jsvals.save_profile = gimp_export_color_profile ();
jsvals.save_profile = (metadata_flags & GIMP_METADATA_SAVE_COLOR_PROFILE) != 0;
parasite = gimp_image_get_parasite (orig_image_ID, "gimp-comment");
if (parasite)
@ -570,6 +570,11 @@ run (const gchar *name,
else
metadata_flags &= ~GIMP_METADATA_SAVE_THUMBNAIL;
if (jsvals.save_profile)
metadata_flags |= GIMP_METADATA_SAVE_COLOR_PROFILE;
else
metadata_flags &= ~GIMP_METADATA_SAVE_COLOR_PROFILE;
file = g_file_new_for_path (param[3].data.d_string);
gimp_image_metadata_save_finish (orig_image_ID,
"image/jpeg",

View File

@ -367,7 +367,7 @@ run (const gchar *name,
tsvals.save_xmp = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
tsvals.save_iptc = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
tsvals.save_thumbnail = (metadata_flags & GIMP_METADATA_SAVE_THUMBNAIL) != 0;
tsvals.save_profile = gimp_export_color_profile ();
tsvals.save_profile = (metadata_flags & GIMP_METADATA_SAVE_COLOR_PROFILE) != 0;
parasite = gimp_image_get_parasite (orig_image, "gimp-comment");
if (parasite)
@ -500,6 +500,11 @@ run (const gchar *name,
/* never save metadata thumbnails for TIFF, see bug #729952 */
metadata_flags &= ~GIMP_METADATA_SAVE_THUMBNAIL;
if (tsvals.save_profile)
metadata_flags |= GIMP_METADATA_SAVE_COLOR_PROFILE;
else
metadata_flags &= ~GIMP_METADATA_SAVE_COLOR_PROFILE;
gimp_image_metadata_save_finish (image,
"image/tiff",
metadata, metadata_flags,