Post Reply 

Basics of Paste Into

Jul 25, 2011, 06:13
Post: #1
Basics of Paste Into
Hi,

I wrote a nifty script that touches up Chroma Key effects in a series of video clips, but I recently ran in to an issue that I need to get cleared up to keep the project rolling.

Pretty basic actually, I just need to cut out a section of the image, do a few processes to what is left behind, then paste the previously cut area back in to the selection, a la the Paste Into Selection function of the GUI version.

Sounds basic but it is giving me trouble. I'm thrown by the verbiage on the Procedure Browser regarding the pasted selection going behind the selected area, etc.

Here's some code and some pseudo code as well:

(gimp-rect-select image 75 20 325 125 0 0 0 )
(gimp-edit-cut drawable)
Do a bunch of stuff to the drawable, including resetting the selection area
(gimp-rect-select image 75 20 325 125 0 0 0 )
here is where I want to paste the previously cut area back where I found it.

Thanks for pointing me in the right direction. Please let me know if I need to post additional code snippets etc.
Find all posts by this user
Quote this message in a reply
Jul 25, 2011, 19:38
Post: #2
RE: Basics of Paste Into
Perfect solution to my issue. Thanks very much.
Find all posts by this user
Quote this message in a reply
Jul 25, 2011, 23:12
Post: #3
RE: Basics of Paste Into
Here is a follow up. Script is working fine when processing a folder of XCF files, but when I do the same for a folder of PNG files it barks at the Add Layer line:

When I use 2 as the layer ID I get this:
>>GIMP-Error: Calling error for procedure 'gimp-image-add-layer':
>>Item 'Background' (2) has already been added to an image

Anything else gives me this:

GIMP-Error: Calling error for procedure 'gimp-image-add-layer':
Procedure 'gimp-image-add-layer' has been called with an invalid ID for argument 'layer'. Most likely a plug-in is trying to work on a layer that doesn't exist any longer.

Here is the relevant snippet:

(gimp-image-crop image 469 380 180 70)
(gimp-layer-copy drawable 0)
(gimp-context-set-background '(20 43 77))
(gimp-by-color-select drawable '(20 43 77) 40 0 1 1 7 0)
(gimp-by-color-select drawable '(59 55 54) 15 0 1 1 7 0)
(gimp-by-color-select drawable '(20 30 47) 18 0 1 1 7 0)
(gimp-edit-clear drawable)
(gimp-selection-none image)
(gimp-image-add-layer image 2 2)
(gimp-layer-add-alpha 2)
(gimp-rect-select image 75 20 325 110 0 0 0 )
(gimp-edit-clear 2)
(gimp-image-merge-visible-layers image 0)
(set! drawable (car (gimp-image-get-active-layer image)))
(gimp-selection-none image)
(gimp-by-color-select drawable '(20 43 77) 15 0 1 1 0 0)
(gimp-selection-grow image 2)
(gimp-edit-clear drawable)

I would love to not convert 1500 png's to xcf and back again. Obviously I am missing something about setting ID layers.

Thanks for any help.
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Is there a "paste multiple layers as images" plugin for GIMP? digiday 21 6,999 Sep 23, 2011 20:58
Last Post: digiday

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS