To copy the visible parts of the image, use these pdb functions:

gimp_image_merge_visible_layers         # combine layers in original file
gimp_rect_select                                        # create a selection (in 
gimp_edit_copy                                  # copy original to clipboard
gimp_edit_paste                                 # paste it as a new floating layer

Exact parameters, and a bit of documentation, are in the PDB. (/Xtns/DB 
Browser ...)

Note that if you just select, then copy, and then paste, Gimp will put the 
floating layer in the center of the new document. Use the 
gimp_layer_translate function to move it to where you want it to go. In 
Python (not sure what the equivalent is in Scheme), I use this code to find 
the physical dimensions of the stuff I want to copy, taking transparency into 

   empty, x1, y1, x2, y2 = pdb.gimp_selection_bounds(originalFile)

Then, using that, I'll calculate the top/right position :

   x = (x1 + x2 - originalFile.width) / 2
   y = (y1 + y2 - originalFile.width) / 2

   # Now, adjust for the position where the old image should be put into the
   # new image
   x = x + top          # top and left are values that I pass in
   y = y + left

   pdb.gimp_layer_translate(floatLayer, x, y)

Good luck!


On Thursday 15 August 2002 12:15 am, Volker Lenhardt wrote:
>  Hi,
>  I'm a script-fu newby and I'm trying to write a script to let up to four
>  pictures be printed on one sheet (DINA4). User selects the files and the
>  border width. The rest is up to the script.
>  The new image for the sheet is established easily. So I started with the
>  first file. I managed to open it and scale it down to a quarter of the
>  sheet.
>  But I cannot find the procedures proper to copy the visible parts of the
>  image (as one layer?) to the sheet image. Please help me.
>  Thanks in advance. Volker

Gimp-user mailing list

Reply via email to