diff --git a/app/core/gimpimage-profile.c b/app/core/gimpimage-profile.c
new file mode 100644
index 0000000000..883fec811e
--- /dev/null
+++ b/app/core/gimpimage-profile.c
@@ -0,0 +1,129 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "config.h"
+
+#include
+
+#include /* lcms.h uses the "inline" keyword */
+
+#include
+
+#include
+#include
+#include
+
+#include "libgimpconfig/gimpconfig.h"
+#include "libgimpcolor/gimpcolor.h"
+#include "libgimpbase/gimpbase.h"
+
+#include "core-types.h"
+
+#include "config/gimpcoreconfig.h"
+
+#include "core/gimp.h"
+#include "gimperror.h"
+#include "gimpimage.h"
+#include "gimpimage-profile.h"
+
+#include "gimp-intl.h"
+
+
+/* public functions */
+
+const GimpParasite *
+gimp_image_get_icc_profile (GimpImage *image)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+ return gimp_image_parasite_find (image, GIMP_ICC_PROFILE_PARASITE_NAME);
+}
+
+void
+gimp_image_set_icc_profile (GimpImage *image,
+ const GimpParasite *icc_profile)
+{
+ g_return_if_fail (GIMP_IS_IMAGE (image));
+
+ if (icc_profile)
+ {
+ g_return_if_fail (strcmp (gimp_parasite_name (icc_profile),
+ GIMP_ICC_PROFILE_PARASITE_NAME) == 0);
+ g_return_if_fail (gimp_parasite_flags (icc_profile) ==
+ (GIMP_PARASITE_PERSISTENT |
+ GIMP_PARASITE_UNDOABLE));
+
+ gimp_image_parasite_attach (image, icc_profile);
+ }
+ else
+ {
+ gimp_image_parasite_detach (image, GIMP_ICC_PROFILE_PARASITE_NAME);
+ }
+}
+
+GimpColorProfile
+gimp_image_get_profile (GimpImage *image,
+ guint8 *md5_digest,
+ GError **error)
+{
+ GimpColorConfig *config;
+ const GimpParasite *parasite;
+ GimpColorProfile *profile = NULL;
+
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ config = image->gimp->config->color_management;
+
+ parasite = gimp_image_get_icc_profile (image);
+
+ if (parasite)
+ {
+ profile = gimp_lcms_profile_open_from_data (gimp_parasite_data (parasite),
+ gimp_parasite_data_size (parasite),
+ md5_digest, error);
+
+ if (! profile)
+ g_prefix_error (error,
+ _("Error parsing data attached as 'icc-profile': "));
+
+ if (profile && ! gimp_lcms_profile_is_rgb (profile))
+ {
+ g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
+ _("Color profile attached as 'icc-profile' is "
+ "not for RGB color space"));
+ cmsCloseProfile (profile);
+ profile = NULL;
+ }
+ }
+ else if (config->rgb_profile)
+ {
+ profile = gimp_lcms_profile_open_from_file (config->rgb_profile,
+ md5_digest, error);
+
+ if (profile && ! gimp_lcms_profile_is_rgb (profile))
+ {
+ g_set_error (error, GIMP_ERROR, GIMP_FAILED,
+ _("Color profile '%s' is not for RGB color space"),
+ gimp_filename_to_utf8 (config->rgb_profile));
+ cmsCloseProfile (profile);
+ profile = NULL;
+ }
+ }
+
+ return profile;
+}
diff --git a/app/core/gimpimage-profile.h b/app/core/gimpimage-profile.h
new file mode 100644
index 0000000000..8d653e663e
--- /dev/null
+++ b/app/core/gimpimage-profile.h
@@ -0,0 +1,34 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef __GIMP_IMAGE_PROFILE_H__
+#define __GIMP_IMAGE_PROFILE_H__
+
+
+#define GIMP_ICC_PROFILE_PARASITE_NAME "icc-profile"
+
+
+const GimpParasite * gimp_image_get_icc_profile (GimpImage *image);
+void gimp_image_set_icc_profile (GimpImage *image,
+ const GimpParasite *icc_profile);
+
+GimpColorProfile gimp_image_get_profile (GimpImage *image,
+ guint8 *md5_digest,
+ GError **error);
+
+
+#endif /* __GIMP_IMAGE_PROFILE_H__ */
diff --git a/app/widgets/gimpimageprofileview.c b/app/widgets/gimpimageprofileview.c
index 9c0e7355e1..68a7a37630 100644
--- a/app/widgets/gimpimageprofileview.c
+++ b/app/widgets/gimpimageprofileview.c
@@ -36,9 +36,6 @@
#include "widgets-types.h"
-#include "config/gimpcoreconfig.h"
-
-#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpimage-profile.h"
@@ -109,43 +106,17 @@ gimp_image_profile_view_update (GimpImageParasiteView *view)
{
GimpImageProfileView *profile_view = GIMP_IMAGE_PROFILE_VIEW (view);
GimpImage *image;
- GimpColorConfig *config;
- const GimpParasite *parasite;
- GimpColorProfile *profile = NULL;
- GError *error = NULL;
+ GimpColorProfile *profile;
+ GError *error = NULL;
- image = gimp_image_parasite_view_get_image (view);
- parasite = gimp_image_parasite_view_get_parasite (view);
+ image = gimp_image_parasite_view_get_image (view);
- config = image->gimp->config->color_management;
+ profile = gimp_image_get_profile (image, NULL, &error);
- if (parasite)
+ if (! profile && error)
{
- profile = gimp_lcms_profile_open_from_data (gimp_parasite_data (parasite),
- gimp_parasite_data_size (parasite),
- NULL, &error);
- if (! profile)
- {
- g_message (_("Error parsing 'icc-profile': %s"), error->message);
- g_clear_error (&error);
- }
- }
- else if (config->rgb_profile)
- {
- profile = gimp_lcms_profile_open_from_file (config->rgb_profile,
- NULL, &error);
- if (! profile)
- {
- g_message ("%s", error->message);
- g_clear_error (&error);
- }
- }
-
- if (profile && ! gimp_lcms_profile_is_rgb (profile))
- {
- g_message (_("Color profile is not for RGB color space (skipping)"));
- cmsCloseProfile (profile);
- profile = NULL;
+ g_message ("%s", error->message);
+ g_clear_error (&error);
}
if (! profile)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6051cf9ddf..6e15e07652 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -128,8 +128,8 @@ app/core/gimp-gradients.c
app/core/gimpgrid.c
app/core/gimpgrouplayer.c
app/core/gimp-gui.c
-app/core/gimpimage-arrange.c
app/core/gimpimage.c
+app/core/gimpimage-arrange.c
app/core/gimpimage-colormap.c
app/core/gimpimage-convert-precision.c
app/core/gimpimage-convert-type.c
@@ -140,6 +140,7 @@ app/core/gimpimage-guides.c
app/core/gimpimage-item-list.c
app/core/gimpimage-merge.c
app/core/gimpimage-new.c
+app/core/gimpimage-profile.c
app/core/gimpimage-quick-mask.c
app/core/gimpimage-resize.c
app/core/gimpimage-sample-points.c