From d7b66476471f180d27dcf0c696dc79838b003837 Mon Sep 17 00:00:00 2001 From: Jehan Date: Sun, 9 Feb 2025 18:50:19 +0100 Subject: [PATCH] =?UTF-8?q?app,=20pdb:=20fix=20implementation=20of=20gimp?= =?UTF-8?q?=5Fimage=5Fautocrop=5Fselected=5Flayers()=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … taking into account drawable's offsets. --- app/pdb/image-autocrop-cmds.c | 11 ++++++++++- pdb/groups/image_autocrop.pdb | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/pdb/image-autocrop-cmds.c b/app/pdb/image-autocrop-cmds.c index af54d42235..40c5e58139 100644 --- a/app/pdb/image-autocrop-cmds.c +++ b/app/pdb/image-autocrop-cmds.c @@ -135,6 +135,10 @@ image_autocrop_selected_layers_invoker (GimpProcedure *procedure, if (layers) { + gint off_x, off_y; + + gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); + switch (gimp_pickable_auto_shrink (GIMP_PICKABLE (drawable), 0, 0, gimp_item_get_width (GIMP_ITEM (drawable)), @@ -146,9 +150,14 @@ image_autocrop_selected_layers_invoker (GimpProcedure *procedure, _("Autocrop layer")); for (iter = layers; iter; iter = iter->next) + { + gint layer_off_x, layer_off_y; + + gimp_item_get_offset (GIMP_ITEM (iter->data), &layer_off_x, &layer_off_y); gimp_item_resize (GIMP_ITEM (iter->data), context, GIMP_FILL_TRANSPARENT, - width, height, -x, -y); + width, height, layer_off_x - (off_x + x), layer_off_y - (off_y + y)); + } gimp_image_undo_group_end (image); break; diff --git a/pdb/groups/image_autocrop.pdb b/pdb/groups/image_autocrop.pdb index e059f0feac..0d49886891 100644 --- a/pdb/groups/image_autocrop.pdb +++ b/pdb/groups/image_autocrop.pdb @@ -119,6 +119,10 @@ HELP if (layers) { + gint off_x, off_y; + + gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); + switch (gimp_pickable_auto_shrink (GIMP_PICKABLE (drawable), 0, 0, gimp_item_get_width (GIMP_ITEM (drawable)), @@ -130,9 +134,14 @@ HELP _("Autocrop layer")); for (iter = layers; iter; iter = iter->next) + { + gint layer_off_x, layer_off_y; + + gimp_item_get_offset (GIMP_ITEM (iter->data), &layer_off_x, &layer_off_y); gimp_item_resize (GIMP_ITEM (iter->data), context, GIMP_FILL_TRANSPARENT, - width, height, -x, -y); + width, height, layer_off_x - (off_x + x), layer_off_y - (off_y + y)); + } gimp_image_undo_group_end (image); break;