Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with Image stacking
#3
A non-optimized way to do it :
Code:
#!/usr/bin/env python
#-*- coding: utf8 -*-

from gimpfu import *


def your_plug_in_function(image, filename, n_copy, x_start, y_start, h_offset, v_offset):
   image.undo_group_start()

   offset_x = x_start
   offset_y = y_start

   if not n_copy:
       return

   for i in range(n_copy):
       layer = pdb.gimp_file_load_layer (image, filename)
       pdb.gimp_layer_set_offsets(layer, offset_x, offset_y)
       image.insert_layer(layer)
       offset_x += h_offset
       offset_y += v_offset

   image.undo_group_end()


register(
   "python_fu_plug_in_name_here",
   "the short plug-in description",
   "the long plug-in description",
   "your name here ",
   "your name here",
   "the year",
   "the plug-in name",
   "*",
   [
       (PF_IMAGE,    "image",    "active image", None),
       (PF_FILENAME, "filename", "File to load", None),
       (PF_INT,      "n_copy",   "Number of image copies", 5),
       (PF_INT,      "x_start",  "x position of the first layer", 0),
       (PF_INT,      "y_start",  "y position of the first layer", 0),
       (PF_INT,      "h_offset", "Horizontal spacing", 1),
       (PF_INT,      "v_offset", "Vertical spacing", 1),
   ],
   [],
   your_plug_in_function, menu="<Image>/csoulman")


main()

Save the above code in a file in the appropriate place (sorry, I'm linux addict, I don't know where windows user must save their plug-ins)
Ensure the file has execution rights.
Run GIMP : you will have a menu called 'csoulman' with one entry : 'the plug-in name'

To improve it :
- load the image only once, then use layer.copy()
- check pdb.gimp_file_load_layer success
Reply


Messages In This Thread
Help with Image stacking - by csoulman - 07-18-2019, 02:53 PM
RE: Help with Image stacking - by Ofnuts - 07-18-2019, 04:08 PM
RE: Help with Image stacking - by tmanni - 07-18-2019, 08:28 PM

Forum Jump: