It is currently Wed Apr 24, 2024 9:15 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: very simple script example needed
PostPosted: Sat May 21, 2016 5:19 am  (#1) 
Offline
GimpChat Member

Joined: Nov 14, 2013
Posts: 101
hello all, Trying for second time to move to Gimp from the other app :)
the biggest headache for me is lack of recordable actions.
There are some things I do that don't involve that many steps but is a hassle to do them over and over by hand.
I thought maybe I could write simple scripts to do those things but when I open a downloaded script to learn from it's too complicated, as it does a lot of steps.
What I need is a script example that only does a few simple things.
For instance one thing I try on images to improve them involves:
Select green channel
paste as layer
set layer mode to softlight, opacity abt 40%
---------
So any example scripts that just make a selection and paste as layer ?

_________________
using Gimp 2.10.8 with Linux on an ancient laptop


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: very simple script example needed
PostPosted: Sat May 21, 2016 5:43 am  (#2) 
Offline
Administrator
User avatar

Joined: Aug 10, 2012
Posts: 13016
Location: Native to NYC living in Arizona, Gimp 2.8 & 2.10, Win 11 PC.
Born2BeMild wrote:
hello all, Trying for second time to move to Gimp from the other app :)
the biggest headache for me is lack of recordable actions.
There are some things I do that don't involve that many steps but is a hassle to do them over and over by hand.
I thought maybe I could write simple scripts to do those things but when I open a downloaded script to learn from it's too complicated, as it does a lot of steps.
What I need is a script example that only does a few simple things.
For instance one thing I try on images to improve them involves:
Select green channel
paste as layer
set layer mode to softlight, opacity abt 40%
---------
So any example scripts that just make a selection and paste as layer ?

I understand your frustration.
What you're looking for is a custom script.
We do have a few really great script writers here on Gimp Chat.
Hopfuly one of them will notice your request and whip up a script for just this purpose.
One such prolific script writer is,
Gimp Chat member trandoductin.

_________________
Image
"A wise man learns more from a foolish question than a fool can learn from a wise answer"
Image


Top
 Post subject: Re: very simple script example needed
PostPosted: Sat May 21, 2016 9:04 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Nov 15, 2014
Posts: 866
I have also wished that the available scripts were fully commented - it would make the learning process much easier.
However, I think it would be unfair to expect the script writers to do that!

david.


Top
 Post subject: Re: very simple script example needed
PostPosted: Sat May 21, 2016 9:46 am  (#4) 
Offline
GimpChat Member

Joined: Nov 14, 2013
Posts: 101
david wrote:
I have also wished that the available scripts were fully commented - it would make the learning process much easier.
However, I think it would be unfair to expect the script writers to do that!

david.

Erm, yes I agree :)

_________________
using Gimp 2.10.8 with Linux on an ancient laptop


Top
 Post subject: Re: very simple script example needed
PostPosted: Sat May 21, 2016 1:02 pm  (#5) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
Inside Gimp,
Help->Procedure Browser
is your friend,
I don't remember any of the names of procedures to call in .scm files...
I just look them all the time every time i have to write a script.
You want to start with script that does nothing, or one that does something but just gut it out so it does nothing then search inside Help->Procedure Browser for procedures that you think they're called and try them out.
For your purpose i don't know if there's way to select channel I tried searching select-channel or channel-select and nothing showed up.
you might want to look at plug-in-decompose
then using the result grab which ever layer
It requires patience and playing around.
You can do it.

_________________
TinT


Top
 Post subject: Re: very simple script example needed
PostPosted: Sat May 21, 2016 5:59 pm  (#6) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
david wrote:
I have also wished that the available scripts were fully commented - it would make the learning process much easier.
However, I think it would be unfair to expect the script writers to do that!

david.


The appropriate level of comment in code is always debatable. My rule is to write comments that I'll find useful 6 months in the future, on a bad day, so this covers mostly the more tricky parts(*) and the unexpected things (aka the WTF factor). General code hygiene (clean structure, well-chosen names) removes the need for most comments.

Writing comments for a beginner would be mostly stating the obvious... and make the code hard to read by non-beginners.

(*) with limits:
Djiskra: "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague."

Kernighan: “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”

_________________
Image


Top
 Post subject: Re: very simple script example needed
PostPosted: Sat May 21, 2016 10:26 pm  (#7) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
here's an example script that does what you asked for ...
the commenting is kind'a repeatitive since the code says the same thing.
hope it helps
Attachment:
MyTest.scm [2.58 KiB]
Downloaded 143 times

_________________
TinT


Top
 Post subject: Re: very simple script example needed
PostPosted: Sun May 22, 2016 8:55 am  (#8) 
Offline
GimpChat Member

Joined: Nov 14, 2013
Posts: 101
@ trandoductin
wow thanks, does exactly what I wanted and is so well commented I can learn from it and change it to do other things with layers.
I notice that is was downloaded x9 before me so others are finding it useful too :)

I have a Question.
near the top of the script (line 9)you have
(green-channel 0)
I thought the red channel was 0 and the green 1 ?

_________________
using Gimp 2.10.8 with Linux on an ancient laptop


Top
 Post subject: Re: very simple script example needed
PostPosted: Sun May 22, 2016 2:50 pm  (#9) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
Born2BeMild wrote:
@ trandoductin
wow thanks, does exactly what I wanted and is so well commented I can learn from it and change it to do other things with layers.
I notice that is was downloaded x9 before me so others are finding it useful too :)

I have a Question.
near the top of the script (line 9)you have
(green-channel 0)
I thought the red channel was 0 and the green 1 ?

Best you know: there are two ways to do scripts in Gimp. One uses Scheme (.scm) and one uses Python (.py). Python is a lot easier to understand (it is the first computer language taught in many places...)(*), can do more things in Gimp, can be used for many things outside of Gimp, and won't cause a premature wear of your "(" and ")" keys.

Take the challenge: take any script here and see how much sense you can make out of it on the first read.

(*) pretty much everywhere it seems, except at the University of Paris where they teach... Scheme. But their excuse for this is "we want to make sure that no student ever used the language before, to put everyone on the same level". I swear I am not making this up. Ofnuts Jr. has already forgotten most of it, and he and his classmates considered this a wicked form of hazing.

_________________
Image


Top
 Post subject: Re: very simple script example needed
PostPosted: Sun May 22, 2016 8:37 pm  (#10) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
Born2BeMild wrote:
@ trandoductin
wow thanks, does exactly what I wanted and is so well commented I can learn from it and change it to do other things with layers.
I notice that is was downloaded x9 before me so others are finding it useful too :)

I have a Question.
near the top of the script (line 9)you have
(green-channel 0)
I thought the red channel was 0 and the green 1 ?

that (green-channel 0) is just the default value, you set it to a value later in the script and it's not 1 like you think it could be any id given by the procedure.
i named it "green-channel", you can name it anything like "channel" if you like.
you can either pre declare a variable and default it to something or you can (define) it as you go along. I have examples of both a pre declared green-channel variable...and set it later and later on in the script i also used (define) to define floating-selection.

_________________
TinT


Top
 Post subject: Re: very simple script example needed
PostPosted: Mon May 23, 2016 3:51 am  (#11) 
Offline
GimpChat Member

Joined: Nov 14, 2013
Posts: 101
thanks trandoductin for the explanation and I even understand it :)
@ ofnuts, I will have a look at one of those python scripts, I am a little familiar with python, have done some basic stuff with it before. I understand you can also use perl to make scripts but don't come across any examples.
There are some video tutorials on youtube for pythonfu
youtube tutorial

_________________
using Gimp 2.10.8 with Linux on an ancient laptop


Top
 Post subject: Re: very simple script example needed
PostPosted: Mon May 23, 2016 4:07 pm  (#12) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
Born2BeMild wrote:
thanks trandoductin for the explanation and I even understand it :)
@ ofnuts, I will have a look at one of those python scripts, I am a little familiar with python, have done some basic stuff with it before. I understand you can also use perl to make scripts but don't come across any examples.
There are some video tutorials on youtube for pythonfu
youtube tutorial


Perl support is not standard in Gimp and so it requires special setup. Futhermore I'm not even sure that it is really up to date.

_________________
Image


Top
 Post subject: Re: very simple script example needed
PostPosted: Tue May 24, 2016 8:50 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Nov 15, 2014
Posts: 866
@ trandoductin,

Many thanks for the commented script. I am rather busy for the next few weeks, but after that I shall do some serious study!

david.


Top
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) GTK help needed text in black needed

5

No new posts Attachment(s) TESTER NEEDED - Test "mixed" GEGL plugins on Gimp 2.99.18 Windows 10

5

No new posts Where is the simple pointer

9

No new posts Attachment(s) Simple pastimes...

5

No new posts Attachment(s) Photo to simple Pencil drawn

34


cron

* Login  



Powered by phpBB3 © phpBB Group