Post Reply 

How to 'Script-Fu' an action....

Jan 16, 2012, 12:02
Post: #1
How to 'Script-Fu' an action....
Hello, Greeting from the cold northeast of the UK.

I have a load of images i want to do the same thing to... and figured a script-fu needed to be created in the console.... problem is, i dont understand where to put my variables.

Please can you help?

What am I trying to do? - I'm taking a scanned image of a black logo which is now a gif. the gif that has 'shades of dark' and black on a transparent background > I am then making a whole new gif which is the same logo (but 100% black) and replacing the original.

1) I open an image FILE > Open > double click.... etc.... it opens as a layer called "Background (100ms)" [please note i have no idea where the 100ms bit comes from - but it does]

2) I can right click the layer thumbnail and 'Alpha to Selection' which works (but i have lots to do so i open the console and had a go ...... I guessed the script-Fu in the console for this is action was....

(gimp-selection-layer-alpha layer)

but where do i type the name of the layer? I always get the message

Error: eval: unbound variable: layer

*at this point i fail to progress any further

anyway..... this is what i hope to do and would love some help please...

1)open a .gif image
2)Alpha to selection' on the layer that just opened. (gimp-selection-layer-alpha layer)
3)Create new layer (gimp-image-add-layer image layer position) ????
4)Fill new layer selection with FG colour (in this case black)
5)turn off original background layer
6)save image as *.gif.


Many thanks
Find all posts by this user
Quote this message in a reply
Jan 16, 2012, 13:24 (This post was last modified: Jan 16, 2012 13:26 by paynekj.)
Post: #2
RE: How to 'Script-Fu' an action....
Welcome from the sunny South West of the UK Wink

Ofnuts gives good advice (as usual), but just to clarify the error you are getting:
(gimp-selection-layer-alpha layer) expects you to pass it the layer-id, which is a number

For instance, if I were to start GIMP and open an image, the image would get an id of 1 and if there is only a single layer in that image, it might have an id of 1
so the call would be (gimp-selection-layer-alpha 1)
BUT the moment you open a new image, or add/delete layers, then the id numbers might be different, so using constants isn't going to work.

Personally I never use the console, but start writing scripts in a text editor.

Kevin
Find all posts by this user
Quote this message in a reply
Jan 16, 2012, 14:12
Post: #3
RE: How to 'Script-Fu' an action....
thank you both.
I used ofnut's 'alphalock' button and did all 78 logos by hand (with a few keyboard shortcuts to make it quicker.....

i'm affraid i couldn't get the numeric thing to work either. i tried in both python and script-fu. but i got a more interesting error message/...

> (gimp-selection-layer-alpha 1)
Error: Procedure execution of gimp-selection-layer-alpha failed on invalid input arguments: Procedure 'gimp-selection-layer-alpha' 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.


is there an 'idiots guide' to scripting fu (or python for that matter) in GIMP.

btw - im running linux mint 12

tahnks
Find all posts by this user
Quote this message in a reply
Jan 16, 2012, 15:14
Post: #4
RE: How to 'Script-Fu' an action....
(Jan 16, 2012 14:12)RickBrock Wrote:  i'm affraid i couldn't get the numeric thing to work either. i tried in both python and script-fu. but i got a more interesting error message/...

> (gimp-selection-layer-alpha 1)
Error: Procedure execution of gimp-selection-layer-alpha failed on invalid input arguments: Procedure 'gimp-selection-layer-alpha' 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.


is there an 'idiots guide' to scripting fu (or python for that matter) in GIMP.

Like I said, the constant "1" is only likely to work in very limited circumstances.

As for guides to scripting (both flavours), The Gimp Chat scripting resource guide is a good place for links: http://gimpchat.com/viewtopic.php?f=9&t=724

And as Ofnuts says, learning by looking at other's scripts is very effective (at least for me it is)
Find all posts by this user
Quote this message in a reply
Jan 16, 2012, 15:40
Post: #5
RE: How to 'Script-Fu' an action....
thanks so much.
God bless.
Rick
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Create new images button & Save as override from Script-fu beniman 12 604 Sep 10, 2014 10:57
Last Post: paynekj
  how to create a shortcut for the action crop? Paul 3 403 Jul 8, 2014 09:26
Last Post: rich2005
  Line Script 2Old 6 673 Feb 6, 2014 18:50
Last Post: 2Old
  How to record action for automatic repeat umen 1 1,009 Aug 23, 2013 20:00
Last Post: umen
  Script Fu Slandingo 1 737 Jun 14, 2013 20:26
Last Post: rich2005

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS