[gimp/gimp-2-10] plug-ins, pdb: remove the unsharp-mask plug-in and add a PDB compat proc



commit e747cbad6b8d548425de036649e0b91418278931
Author: Michael Natterer <mitch gimp org>
Date:   Sat Jul 14 17:11:25 2018 +0200

    plug-ins, pdb: remove the unsharp-mask plug-in and add a PDB compat proc
    
    (cherry picked from commit 680642e37ce40ec841d6c87d7166b186670af0e0)

 app/pdb/internal-procs.c       |   2 +-
 app/pdb/plug-in-compat-cmds.c  | 100 +++++
 pdb/groups/plug_in_compat.pdb  |  56 +++
 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/unsharp-mask.c | 957 -----------------------------------------
 po-plug-ins/POTFILES.in        |   1 -
 9 files changed, 157 insertions(+), 981 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 073c6e67cd..179a93cba4 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 840 procedures registered total */
+/* 841 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 b8c4e4ac93..17e1a48549 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -3981,6 +3981,52 @@ plug_in_threshold_alpha_invoker (GimpProcedure         *procedure,
                                            error ? *error : NULL);
 }
 
+static GimpValueArray *
+plug_in_unsharp_mask_invoker (GimpProcedure         *procedure,
+                              Gimp                  *gimp,
+                              GimpContext           *context,
+                              GimpProgress          *progress,
+                              const GimpValueArray  *args,
+                              GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gdouble radius;
+  gdouble amount;
+  gint32 threshold;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  radius = g_value_get_double (gimp_value_array_index (args, 3));
+  amount = g_value_get_double (gimp_value_array_index (args, 4));
+  threshold = g_value_get_int (gimp_value_array_index (args, 5));
+
+  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:unsharp-mask",
+                                 "std-dev",   radius,
+                                 "scale",     amount,
+                                 "threshold", threshold / 255.0,
+                                 NULL);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Sharpen (Unsharp Mask)"),
+                                         node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
 static GimpValueArray *
 plug_in_video_invoker (GimpProcedure         *procedure,
                        Gimp                  *gimp,
@@ -8276,6 +8322,60 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
 
+  /*
+   * gimp-plug-in-unsharp-mask
+   */
+  procedure = gimp_procedure_new (plug_in_unsharp_mask_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-unsharp-mask");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-unsharp-mask",
+                                     "The most widely useful method for sharpening an image",
+                                     "The unsharp mask is a sharpening filter that works by comparing using 
the difference of the image and a blurred version of the image. It is commonly used on photographic images, 
and is provides a much more pleasing result than the standard sharpen filter.",
+                                     "Compatibility procedure. Please see 'gegl:unsharp-mask' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:unsharp-mask' for credits.",
+                                     "2018",
+                                     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,
+                               g_param_spec_double ("radius",
+                                                    "radius",
+                                                    "Radius of gaussian blur",
+                                                    0.0, 300.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("amount",
+                                                    "amount",
+                                                    "Strength of effect",
+                                                    0.0, 300.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("threshold",
+                                                      "threshold",
+                                                      "Threshold",
+                                                      0, 255, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
   /*
    * gimp-plug-in-video
    */
diff --git a/pdb/groups/plug_in_compat.pdb b/pdb/groups/plug_in_compat.pdb
index 9d5e17bb47..37b90bd7dd 100644
--- a/pdb/groups/plug_in_compat.pdb
+++ b/pdb/groups/plug_in_compat.pdb
@@ -4120,6 +4120,61 @@ CODE
     );
 }
 
+sub plug_in_unsharp_mask {
+    $blurb = "The most widely useful method for sharpening an image";
+
+    $help = <<'HELP';
+The unsharp mask is a sharpening filter that works by comparing using
+the difference of the image and a blurred version of the image.  It is
+commonly used on photographic images, and is provides a much more
+pleasing result than the standard sharpen filter.
+HELP
+
+    &std_pdb_compat('gegl:unsharp-mask');
+    $date = '2018';
+
+    @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 => 'radius', type => '0.0 <= float <= 300.0',
+         desc => 'Radius of gaussian blur' },
+       { name => 'amount', type => '0.0 <= float <= 300.0',
+         desc => 'Strength of effect' },
+       { name => 'threshold', type => '0 <= int32 <= 255',
+         desc => 'Threshold' }
+    );
+
+    %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:unsharp-mask",
+                             "std-dev",   radius,
+                             "scale",     amount,
+                             "threshold", threshold / 255.0,
+                             NULL);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Sharpen (Unsharp Mask)"),
+                                     node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_video {
     $blurb = 'Simulate distortion produced by a fuzzy or low-res monitor';
 
@@ -5028,6 +5083,7 @@ CODE
             plug_in_solid_noise
             plug_in_spread
             plug_in_threshold_alpha
+            plug_in_unsharp_mask
             plug_in_video
             plug_in_vinvert
             plug_in_vpropagate
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 32fd95ef9e..2c0538e5e6 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -178,8 +178,6 @@
 /tile-small.exe
 /unit-editor
 /unit-editor.exe
-/unsharp-mask
-/unsharp-mask.exe
 /van-gogh-lic
 /van-gogh-lic.exe
 /warp
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 9d5314745d..d3024ae717 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -137,7 +137,6 @@ libexec_PROGRAMS = \
        tile \
        tile-small \
        unit-editor \
-       unsharp-mask \
        van-gogh-lic \
        warp \
        wavelet-decompose \
@@ -1722,23 +1721,6 @@ unit_editor_LDADD = \
        $(INTLLIBS)             \
        $(unit_editor_RC)
 
-unsharp_mask_SOURCES = \
-       unsharp-mask.c
-
-unsharp_mask_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(unsharp_mask_RC)
-
 van_gogh_lic_SOURCES = \
        van-gogh-lic.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index bb19ffba87..d47b82f171 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -86,7 +86,6 @@ sphere_designer_RC = sphere-designer.rc.o
 tile_RC = tile.rc.o
 tile_small_RC = tile-small.rc.o
 unit_editor_RC = unit-editor.rc.o
-unsharp_mask_RC = unsharp-mask.rc.o
 van_gogh_lic_RC = van-gogh-lic.rc.o
 warp_RC = warp.rc.o
 wavelet_decompose_RC = wavelet-decompose.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 46c4052ca9..4dcffbdca9 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -87,7 +87,6 @@
     'tile' => { ui => 1, gegl => 1 },
     'tile-small' => { ui => 1 },
     'unit-editor' => { ui => 1 },
-    'unsharp-mask' => { ui => 1 },
     'van-gogh-lic' => { ui => 1 },
     'warp' => { ui => 1 },
     'wavelet-decompose' => { ui => 1, gegl => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index a5f7f2253d..2d900e097d 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -91,7 +91,6 @@ plug-ins/common/sphere-designer.c
 plug-ins/common/tile.c
 plug-ins/common/tile-small.c
 plug-ins/common/unit-editor.c
-plug-ins/common/unsharp-mask.c
 plug-ins/common/van-gogh-lic.c
 plug-ins/common/warp.c
 plug-ins/common/wavelet-decompose.c


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