diff --git a/app/actions/filters-actions.c b/app/actions/filters-actions.c
index 41c4b838a3..af76ff0fbc 100644
--- a/app/actions/filters-actions.c
+++ b/app/actions/filters-actions.c
@@ -69,6 +69,12 @@ static const GimpStringActionEntry filters_actions[] =
"gegl:polar-coordinates",
NULL /* FIXME GIMP_HELP_FILTER_POLAR_COORDINATES */ },
+ { "filters-semi-flatten", GIMP_STOCK_GEGL,
+ NC_("filters-action", "_Semi-Flatten..."), NULL,
+ NC_("filters-action", "Replace partial transparency with a color"),
+ "gimp:semi-flatten",
+ NULL /* FIXME GIMP_HELP_FILTER_POLAR_COORDINATES */ },
+
{ "filters-threshold-alpha", GIMP_STOCK_GEGL,
NC_("filters-action", "_Threshold Alpha..."), NULL,
NC_("filters-action", "Make transparency all-or-nothing"),
diff --git a/app/gegl/Makefile.am b/app/gegl/Makefile.am
index 03dc76544e..b8ff03a72f 100644
--- a/app/gegl/Makefile.am
+++ b/app/gegl/Makefile.am
@@ -72,6 +72,8 @@ libappgegl_a_sources = \
gimpoperationhistogramsink.h \
gimpoperationmaskcomponents.c \
gimpoperationmaskcomponents.h \
+ gimpoperationsemiflatten.c \
+ gimpoperationsemiflatten.h \
gimpoperationsetalpha.c \
gimpoperationsetalpha.h \
gimpoperationshapeburst.c \
diff --git a/app/gegl/gimp-gegl.c b/app/gegl/gimp-gegl.c
index 2e78d24be5..f77477e71b 100644
--- a/app/gegl/gimp-gegl.c
+++ b/app/gegl/gimp-gegl.c
@@ -40,6 +40,7 @@
#include "gimpoperationgrow.h"
#include "gimpoperationhistogramsink.h"
#include "gimpoperationmaskcomponents.h"
+#include "gimpoperationsemiflatten.h"
#include "gimpoperationsetalpha.h"
#include "gimpoperationshapeburst.h"
#include "gimpoperationshrink.h"
@@ -123,6 +124,7 @@ gimp_gegl_init (Gimp *gimp)
g_type_class_ref (GIMP_TYPE_OPERATION_GROW);
g_type_class_ref (GIMP_TYPE_OPERATION_HISTOGRAM_SINK);
g_type_class_ref (GIMP_TYPE_OPERATION_MASK_COMPONENTS);
+ g_type_class_ref (GIMP_TYPE_OPERATION_SEMI_FLATTEN);
g_type_class_ref (GIMP_TYPE_OPERATION_SET_ALPHA);
g_type_class_ref (GIMP_TYPE_OPERATION_SHAPEBURST);
g_type_class_ref (GIMP_TYPE_OPERATION_SHRINK);
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index d146c38446..af8522a887 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 675 procedures registered total */
+/* 676 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 aca986a36a..5371b9136b 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -32,6 +32,7 @@
#include "pdb-types.h"
+#include "core/gimpcontext.h"
#include "core/gimpdrawable-operation.h"
#include "core/gimpdrawable.h"
#include "core/gimpparamspecs.h"
@@ -225,6 +226,50 @@ plug_in_polar_coords_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
+static GimpValueArray *
+plug_in_semiflatten_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ GimpDrawable *drawable;
+
+ drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+
+ if (success)
+ {
+ if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+ gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+ gimp_drawable_has_alpha (drawable))
+ {
+ GeglNode *node;
+ GimpRGB color;
+
+ gimp_context_get_background (context, &color);
+
+ node =
+ gegl_node_new_child (NULL,
+ "operation", "gimp:semi-flatten",
+ "color", &color,
+ NULL);
+
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Semi-Flatten"),
+ node);
+
+ g_object_unref (node);
+ }
+ else
+ success = FALSE;
+ }
+
+ return gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+}
+
static GimpValueArray *
plug_in_threshold_alpha_invoker (GimpProcedure *procedure,
Gimp *gimp,
@@ -507,6 +552,42 @@ register_plug_in_compat_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
+ /*
+ * gimp-plug-in-semiflatten
+ */
+ procedure = gimp_procedure_new (plug_in_semiflatten_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "plug-in-semiflatten");
+ gimp_procedure_set_static_strings (procedure,
+ "plug-in-semiflatten",
+ "Replace partial transparency with the current background color",
+ "This plugin flattens pixels in an RGBA image that aren't completely transparent against the current GIMP background color.",
+ "Spencer Kimball & Peter Mattis",
+ "Spencer Kimball & Peter Mattis",
+ "1997",
+ 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_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
/*
* gimp-plug-in-threshold-alpha
*/
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index bcb3eac71d..2ab542958d 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -431,6 +431,7 @@
+