Skip to content

Instantly share code, notes, and snippets.

@pabloasanchez
Created May 22, 2023 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pabloasanchez/2c7db815fca83562ceaaed1f836481c6 to your computer and use it in GitHub Desktop.
Save pabloasanchez/2c7db815fca83562ceaaed1f836481c6 to your computer and use it in GitHub Desktop.
A simple GIMP plugin for copying layers.
#!/usr/bin/env python
# A simple plugin for copying layers.
# The layers can be copied in normal or reverse order,
# and can be placed at the top or bottom of the destination's layers,
# or above the selected layer in the destination.
from gimpfu import *
def copy_layers(origin, dest, order, position):
images = gimp.image_list()
layers = origin.layers if order == 1 else reversed(origin.layers)
if position == 0:
insertion = 0
elif position == 1:
insertion = len(dest.layers)
else:
insertion = -1
pdb.gimp_undo_push_group_start(dest)
for origin_layer in layers:
copied_layer = pdb.gimp_layer_new_from_drawable(origin_layer, dest)
gimp.progress_init("Processing" + copied_layer.name + "...")
pdb.gimp_image_insert_layer(dest, copied_layer, None, insertion)
pdb.gimp_undo_push_group_end(dest)
# gimp.message("Success")
register(
"copy_layers",
"A simple plugin for copying layers. \nThe layers can be copied in normal or reverse order, \nand can be placed at the top or bottom of the destination's layers, \nor above the selected layer in the destination.",
"Simple layer copying plug-in",
"Pablo Sanchez",
"MIT License",
"2023",
"Copy Layers",
"",
[
(PF_IMAGE, "image", "Source image", None),
(PF_IMAGE, "image", "Destination image", None),
(PF_OPTION, "option", "Order", 1, ("Normal", "Reverse")),
(PF_OPTION, "option", "Position", 1, ("Top", "Bottom", "Above the selected layer")),
],
[],
copy_layers,
menu="<Image>/Filters/User")
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment