[gimp] plug-ins: remove plug-in red-eye-removal and add a PDB compat proc for it



commit b8dace7a75629d87abfa4512b96947d029674228
Author: Michael Natterer <mitch gimp org>
Date:   Sun May 19 21:11:03 2013 +0200

    plug-ins: remove plug-in red-eye-removal and add a PDB compat proc for it

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |   83 +++++++
 plug-ins/common/.gitignore          |    2 -
 plug-ins/common/Makefile.am         |   18 --
 plug-ins/common/gimprc.common       |    1 -
 plug-ins/common/plugin-defs.pl      |    1 -
 plug-ins/common/red-eye-removal.c   |  409 -----------------------------------
 po-plug-ins/POTFILES.in             |    1 -
 tools/pdbgen/pdb/plug_in_compat.pdb |   51 +++++
 9 files changed, 135 insertions(+), 433 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 38cea33..60e4ad6 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 684 procedures registered total */
+/* 685 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c
index 15be099..912836a 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -335,6 +335,47 @@ plug_in_polar_coords_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_red_eye_removal_invoker (GimpProcedure         *procedure,
+                                 Gimp                  *gimp,
+                                 GimpContext           *context,
+                                 GimpProgress          *progress,
+                                 const GimpValueArray  *args,
+                                 GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gint32 threshold;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  threshold = g_value_get_int (gimp_value_array_index (args, 3));
+
+  if (success)
+    {
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                     GIMP_PDB_ITEM_CONTENT, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+        {
+          GeglNode *node =
+            gegl_node_new_child (NULL,
+                                 "operation", "gegl:red-eye-removal",
+                                 "threshold", (gdouble) (threshold - 50) / 50.0 * 0.2 + 0.4,
+                                 NULL);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Red Eye Removal"),
+                                         node);
+
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_randomize_hurl_invoker (GimpProcedure         *procedure,
                                 Gimp                  *gimp,
                                 GimpContext           *context,
@@ -898,6 +939,48 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-red-eye-removal
+   */
+  procedure = gimp_procedure_new (plug_in_red_eye_removal_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-red-eye-removal");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-red-eye-removal",
+                                     "Remove the red eye effect caused by camera flashes",
+                                     "This procedure removes the red eye effect caused by camera flashes by 
using a percentage based red color threshold. Make a selection containing the eyes, and apply the filter 
while adjusting the threshold to accurately remove the red eyes.",
+                                     "Compatibility procedure. Please see 'gegl:red-eye-removal' for 
credits.",
+                                     "Compatibility procedure. Please see 'gegl:red-eye-removal' for 
credits.",
+                                     "2013",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_enum ("run-mode",
+                                                  "run mode",
+                                                  "The run mode",
+                                                  GIMP_TYPE_RUN_MODE,
+                                                  GIMP_RUN_INTERACTIVE,
+                                                  GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_image_id ("image",
+                                                         "image",
+                                                         "Input image (unused)",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_drawable_id ("drawable",
+                                                            "drawable",
+                                                            "Input drawable",
+                                                            pdb->gimp, FALSE,
+                                                            GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("threshold",
+                                                      "threshold",
+                                                      "Red eye threshold in percent",
+                                                      0, 100, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-randomize-hurl
    */
   procedure = gimp_procedure_new (plug_in_randomize_hurl_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 6ca7861..68e1695 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -224,8 +224,6 @@
 /procedure-browser.exe
 /qbist
 /qbist.exe
-/red-eye-removal
-/red-eye-removal.exe
 /ripple
 /ripple.exe
 /rotate
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index d6db081..30d1962 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -155,7 +155,6 @@ libexec_PROGRAMS = \
        plugin-browser \
        procedure-browser \
        qbist \
-       red-eye-removal \
        ripple \
        rotate \
        sample-colorize \
@@ -2135,23 +2134,6 @@ qbist_LDADD = \
        $(INTLLIBS)             \
        $(qbist_RC)
 
-red_eye_removal_SOURCES = \
-       red-eye-removal.c
-
-red_eye_removal_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(red_eye_removal_RC)
-
 ripple_SOURCES = \
        ripple.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index f4faa7d..e599d67 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -109,7 +109,6 @@ plasma_RC = plasma.rc.o
 plugin_browser_RC = plugin-browser.rc.o
 procedure_browser_RC = procedure-browser.rc.o
 qbist_RC = qbist.rc.o
-red_eye_removal_RC = red-eye-removal.rc.o
 ripple_RC = ripple.rc.o
 rotate_RC = rotate.rc.o
 sample_colorize_RC = sample-colorize.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 00f345a..b02d721 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -110,7 +110,6 @@
     'plugin-browser' => { ui => 1 },
     'procedure-browser' => { ui => 1 },
     'qbist' => { ui => 1 },
-    'red-eye-removal' => { ui => 1 },
     'ripple' => { ui => 1 },
     'rotate' => {},
     'sample-colorize' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index fbcea7d..411e9be 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -117,7 +117,6 @@ plug-ins/common/plasma.c
 plug-ins/common/plugin-browser.c
 plug-ins/common/procedure-browser.c
 plug-ins/common/qbist.c
-plug-ins/common/red-eye-removal.c
 plug-ins/common/ripple.c
 plug-ins/common/rotate.c
 plug-ins/common/sample-colorize.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index cab29e0..20b7996 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -521,6 +521,56 @@ CODE
     );
 }
 
+sub plug_in_red_eye_removal {
+    $blurb = 'Remove the red eye effect caused by camera flashes';
+
+    $help = <<'HELP';
+This procedure removes the red eye effect caused by camera flashes by
+using a percentage based red color threshold.  Make a selection
+containing the eyes, and apply the filter while adjusting the
+threshold to accurately remove the red eyes.
+HELP
+
+    &std_pdb_compat('gegl:red-eye-removal');
+    $date = '2013';
+
+    @inargs = (
+       { name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
+         desc => 'The run mode' },
+       { name => 'image', type => 'image', dead => 1,
+         desc => 'Input image (unused)' },
+       { name => 'drawable', type => 'drawable',
+         desc => 'Input drawable' },
+       { name => 'threshold', type => '0 <= int32 <= 100',
+         desc => 'Red eye threshold in percent' }
+    );
+
+    %invoke = (
+       code => <<'CODE'
+{
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                 GIMP_PDB_ITEM_CONTENT, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+    {
+      GeglNode *node =
+        gegl_node_new_child (NULL,
+                             "operation", "gegl:red-eye-removal",
+                             "threshold", (gdouble) (threshold - 50) / 50.0 * 0.2 + 0.4,
+                             NULL);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Red Eye Removal"),
+                                     node);
+
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_semiflatten {
     $blurb = 'Replace partial transparency with the current background color';
 
@@ -688,6 +738,7 @@ CODE
             plug_in_pixelize
             plug_in_pixelize2
             plug_in_polar_coords
+           plug_in_red_eye_removal
             plug_in_randomize_hurl
             plug_in_randomize_pick
             plug_in_randomize_slur


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