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;