For plug-in writers reference, these are equivalent: - (plug-in-bump-map RUN-NONINTERACTIVE img drawable bump-layer azimuth elevation depth 0 0 0 0 FALSE FALSE 0) + (let* ((filter (car (gimp-drawable-filter-new drawable "gegl:bump-map" "")))) + (gimp-drawable-filter-configure filter LAYER-MODE-REPLACE 1.0 + "azimuth" azimuth "elevation" elevation "depth" depth + "offset-x" 0 "offset-y" 0 "waterlevel" 0.0 "ambient" 0.0 + "compensate" FALSE "invert" FALSE "type" "linear" + "tiled" FALSE) + (gimp-drawable-filter-set-aux-input filter "aux" bump-layer) + (gimp-drawable-merge-filter drawable filter) + ) The "type" argument now uses strings. This commit also do a big cleanup of remaining now-unused helper functions in the compat PDB code.
178 lines
5.5 KiB
Text
178 lines
5.5 KiB
Text
# 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 <https://www.gnu.org/licenses/>.
|
|
|
|
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
|
|
|
|
|
|
# The declared ranges generate min/max in GParamSpecs
|
|
# and the min becomes the default in the GParamSpecs.
|
|
# A declared range must correspond with range declared in GEGL
|
|
# else args defaulted from min may generate out-of-range warnings.
|
|
|
|
sub plug_in_autocrop {
|
|
$blurb = 'Remove empty borders from the image';
|
|
|
|
$help = <<'HELP';
|
|
Remove empty borders from the image.
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
$date = '1997';
|
|
|
|
@inargs = (
|
|
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
|
|
desc => 'The run mode' },
|
|
{ name => 'image', type => 'image',
|
|
desc => 'Input image)' },
|
|
{ name => 'drawable', type => 'drawable',
|
|
desc => 'Input drawable' }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
|
|
GIMP_PDB_ITEM_CONTENT, error))
|
|
{
|
|
gint x, y, width, height;
|
|
gint off_x, off_y;
|
|
|
|
gimp_pickable_auto_shrink (GIMP_PICKABLE (drawable),
|
|
0, 0,
|
|
gimp_item_get_width (GIMP_ITEM (drawable)),
|
|
gimp_item_get_height (GIMP_ITEM (drawable)),
|
|
&x, &y, &width, &height);
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
|
x += off_x;
|
|
y += off_y;
|
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
|
|
_("Autocrop image"));
|
|
|
|
if (x < 0 ||
|
|
y < 0 ||
|
|
x + width > gimp_image_get_width (image) ||
|
|
y + height > gimp_image_get_height (image))
|
|
{
|
|
/*
|
|
* partially outside the image area, we need to
|
|
* resize the image to be able to crop properly.
|
|
*/
|
|
gimp_image_resize (image, context, width, height, -x, -y, NULL);
|
|
|
|
x = y = 0;
|
|
}
|
|
|
|
gimp_image_crop (image, context, GIMP_FILL_TRANSPARENT,
|
|
x, y, width, height, TRUE);
|
|
|
|
gimp_image_undo_group_end (image);
|
|
}
|
|
else
|
|
success = FALSE;
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub plug_in_autocrop_layer {
|
|
$blurb = 'Crop the selected layers based on empty borders of the input drawable';
|
|
|
|
$help = <<'HELP';
|
|
Crop the selected layers of the input "image" based on empty borders of the input "drawable".
|
|
\n\nThe input drawable serves as a base for detecting cropping extents (transparency or background color), and is not necessarily among the cropped layers (the current selected layers).
|
|
HELP
|
|
|
|
&std_pdb_misc;
|
|
$date = '1997';
|
|
|
|
@inargs = (
|
|
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
|
|
desc => 'The run mode' },
|
|
{ name => 'image', type => 'image',
|
|
desc => 'Input image)' },
|
|
{ name => 'drawable', type => 'drawable',
|
|
desc => 'Input drawable' }
|
|
);
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
|
|
GIMP_PDB_ITEM_CONTENT, error))
|
|
{
|
|
GList *layers = gimp_image_get_selected_layers (image);
|
|
GList *iter;
|
|
gint x, y, width, height;
|
|
|
|
if (layers)
|
|
{
|
|
switch (gimp_pickable_auto_shrink (GIMP_PICKABLE (drawable),
|
|
0, 0,
|
|
gimp_item_get_width (GIMP_ITEM (drawable)),
|
|
gimp_item_get_height (GIMP_ITEM (drawable)),
|
|
&x, &y, &width, &height))
|
|
{
|
|
case GIMP_AUTO_SHRINK_SHRINK:
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
|
|
_("Autocrop layer"));
|
|
|
|
for (iter = layers; iter; iter = iter->next)
|
|
gimp_item_resize (GIMP_ITEM (iter->data),
|
|
context, GIMP_FILL_TRANSPARENT,
|
|
width, height, -x, -y);
|
|
|
|
gimp_image_undo_group_end (image);
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
success = FALSE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
success = FALSE;
|
|
}
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
@headers = qw("core/gimpimage-crop.h"
|
|
"core/gimpimage-resize.h"
|
|
"core/gimpimage-undo.h"
|
|
"core/gimppickable.h"
|
|
"core/gimppickable-auto-shrink.h"
|
|
"gimppdb-utils.h"
|
|
"gimp-intl.h");
|
|
|
|
@procs = qw(plug_in_autocrop
|
|
plug_in_autocrop_layer);
|
|
|
|
%exports = (app => [@procs], lib => []);
|
|
|
|
$desc = 'Plug-in Compat';
|
|
$doc_title = 'gimpplugincompat';
|
|
$doc_short_desc = 'Compatibility for removed plug-ins.';
|
|
$doc_long_desc = 'Functions that perform the operation of removed plug-ins using GEGL operations or other GIMP internal functions.';
|
|
|
|
1;
|