It is currently Wed Jul 24, 2024 6:25 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Test script-fu in console
PostPosted: Sat Feb 08, 2014 5:48 am  (#1) 
Offline
New Member

Joined: Feb 08, 2014
Posts: 2
Hello!

I'm new here and having some troubles with Script-Fu. I'd like to test some commands in the console before using them in a script, but I can't find out how to specify the parameters needed.

For example: I have an image loaded and I want to invert the colors. The Script-Fu procedure browser states that the only parameter needed for the gimp-invert command is a drawable. My question: what do I have to type in the place of <drawable>in the next line to invert the colors of my image?

(gimp-invert <drawable>)

I think I miss something basic...


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Test script-fu in console
PostPosted: Sat Feb 08, 2014 6:30 am  (#2) 
Online
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14728
Location: USA
wouter wrote:
Hello!

I'm new here and having some troubles with Script-Fu. I'd like to test some commands in the console before using them in a script, but I can't find out how to specify the parameters needed.

For example: I have an image loaded and I want to invert the colors. The Script-Fu procedure browser states that the only parameter needed for the gimp-invert command is a drawable. My question: what do I have to type in the place of <drawable>in the next line to invert the colors of my image?

(gimp-invert <drawable>)

I think I miss something basic...


Drawable can be a layer or image or a author defined variable such as MyLayer or ThisChannel.

(define (script-fu-whatever-here image layer))
(gimp-invert image)

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Test script-fu in console
PostPosted: Sat Feb 08, 2014 6:56 am  (#3) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
If your drawable is a layer*, you can open up one of the dialogs that operate on layers ("Layer->Scale Layer...", "Layer->Set Layer Boundary Size...", any command in the Layer menu with ellipses at the end will open a dialog), and find the numeric value of the drawable identifier at the top of the dialog. The number that follows the layer name is the ID of the drawable. Once you find the ID of the drawable, you can Cancel the dialog.

For example, in the following screenshot the layer's ID (highlighted in blue) would "104". So (gimp-invert 104) would invert the colors of (the selected portion of) that layer.

Attachment:
File comment: Dialog with layer ID highlighted in blue
SS-layer-id.png
SS-layer-id.png [ 130.85 KiB | Viewed 2220 times ]


A similar approach works for the image, channel, and path IDs; just open a menu command that raises a dialog and look for the ID at the top.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Last edited by saulgoode on Sat Feb 08, 2014 10:00 am, edited 1 time in total.

Top
 Post subject: Re: Test script-fu in console
PostPosted: Sat Feb 08, 2014 7:57 am  (#4) 
Offline
Script Coder
User avatar

Joined: Nov 06, 2012
Posts: 239
Location: Italy
Hi wouter and welcome to Gimp Chat. :)

As saulgoode and Rod correctly pointed out, the drawable objects of any open image in GIMP (namely layers, channels and paths) are detected and recognized in Script-Fu by means of the univocal integer numbers representing their identifiers.

Considering that most times it is not so straightforward to track down these numbers with GIMP, I would like to recommend you a script of mine called "Identify Image Objects" whose purpose is exactly to rename the items contained in an open image by causing the new name of each drawable or path to display the relevant identifier:
http://registry.gimp.org/node/24996

Having these identifiers available and visible all at once and all together allows you to test with greater ease those types of procedures through the console, so I hope this script can be worthwhile for you in this regard.

_________________
Gino D's GIMP scripts: https://sites.google.com/site/ginodonig/gimp-scripts


Top
 Post subject: Re: Test script-fu in console
PostPosted: Sat Feb 08, 2014 10:04 am  (#5) 
Offline
New Member

Joined: Feb 08, 2014
Posts: 2
Thank you all for your response. You helped! And Gino, your script comes in very handy to know the ID's!


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Cannot run test script-fu script via console

7

No new posts GIMP 2.10 console etc Macbook

0

No new posts Attachment(s) pm_create_a_depthmap_image.py (Test)

8

No new posts Jewelry Text Test

8



* Login  



Powered by phpBB3 © phpBB Group