[gegl] icc-save: new operation



commit f0427eddf08954bbebc2cab7a5c357d95d3eb346
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Jul 11 17:10:01 2018 +0200

    icc-save: new operation

 operations/common/Makefile.am |  1 +
 operations/common/icc-save.c  | 81 +++++++++++++++++++++++++++++++++++++++++++
 po/POTFILES.in                |  1 +
 3 files changed, 83 insertions(+)
---
diff --git a/operations/common/Makefile.am b/operations/common/Makefile.am
index 75c5e4837..be538c6a6 100644
--- a/operations/common/Makefile.am
+++ b/operations/common/Makefile.am
@@ -53,6 +53,7 @@ gegl_common_la_SOURCES =\
        grid.c \
        high-pass.c \
        hue-chroma.c \
+       icc-save.c \
        image-compare.c \
        image-gradient.c \
        introspect.c \
diff --git a/operations/common/icc-save.c b/operations/common/icc-save.c
new file mode 100644
index 000000000..0390599d6
--- /dev/null
+++ b/operations/common/icc-save.c
@@ -0,0 +1,81 @@
+/* This file is an image processing operation for GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2018 Øyvind Kolås <pippin gimp org>
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+
+#ifdef GEGL_PROPERTIES
+
+property_file_path (path, _("File"), "")
+  description (_("Target path and filename"))
+
+#else
+
+#define GEGL_OP_SINK
+#define GEGL_OP_NAME     icc_save
+#define GEGL_OP_C_SOURCE icc-save.c
+
+#include <gegl-op.h>
+#include <gegl-gio-private.h>
+
+
+static gboolean
+process (GeglOperation       *operation,
+         GeglBuffer          *input,
+         const GeglRectangle *result,
+         int                  level)
+{
+  GeglProperties *o = GEGL_PROPERTIES (operation);
+  const Babl *space = babl_format_get_space (gegl_buffer_get_format (input));
+  int icc_len;
+  const char *name = babl_get_name (space);
+  const char *icc_profile;
+  if (strlen (name) > 10) name = "babl/GEGL";
+  icc_profile = babl_space_get_icc (space, &icc_len);
+  if (icc_profile)
+  {
+    g_file_set_contents (o->path, icc_profile, icc_len, NULL);
+  }
+
+  return  TRUE;
+}
+
+static void
+gegl_op_class_init (GeglOpClass *klass)
+{
+  GeglOperationClass     *operation_class;
+  GeglOperationSinkClass *sink_class;
+
+  operation_class = GEGL_OPERATION_CLASS (klass);
+  sink_class      = GEGL_OPERATION_SINK_CLASS (klass);
+
+  sink_class->process    = process;
+
+  gegl_operation_class_set_keys (operation_class,
+    "name",          "gegl:icc-save",
+    "title",       _("ICC profile saver"),
+    "categories",    "output",
+    "description", _("Stores the ICC profile that would be embedded if stored as an image."),
+    NULL);
+
+  gegl_operation_handlers_register_saver (
+    ".icc", "gegl:icc-save");
+}
+
+#endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 544473ea4..875277cda 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -44,6 +44,7 @@ operations/common/grey.c
 operations/common/grid.c
 operations/common/high-pass.c
 operations/common/hue-chroma.c
+operations/common/icc-save.c
 operations/common/image-compare.c
 operations/common/image-gradient.c
 operations/common/introspect.c


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]