It is currently Fri Jun 12, 2026 5:52 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Script interact with user
PostPosted: Sun Dec 27, 2015 6:55 pm  (#1) 
Offline
New Member

Joined: Dec 27, 2015
Posts: 3
GIMP Version: 2.8.10
Operating System: Linux
OS Version: 3.13.0-34-generic x86_64 Debian-based
GIMP Experience: Intermediate Level



Is there possibility to interact with user from script-fu?

For example, in case of process negative film scan i want to invert image, rotate it (this i already can do with script-fu), then i want to select area to crop image (each image has own crop region) -- and this is reason of trouble. I do not know offset, width and height parameters for gimp-image-crop, and i could not find how do this.

Next i wish to call curve dialog (not simply gimp-curves-explicit), make curve manually and then apply this. And this is my second trouble. How can i invoke curve dialog?


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: Script interact with user
PostPosted: Sun Dec 27, 2015 8:02 pm  (#2) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4469
Location: Canada
If you have an active selection before running script you can use

(define bounds (gimp-selection-bounds image))
(if (= (list-ref bounds 0) TRUE)
   (begin
      ;there's selection
      (gimp-image-crop image (- (list-ref bounds 3) (list-ref bounds 1)) ;width
                        (- (list-ref bounds 4) (list-ref bounds 2)) ;height
                        (list-ref bounds 1)                         ;offsetx
                        (list-ref bounds 2)                         ;offsety
      )
      
   )
   (begin
      ;else do nothing there's no selection
   )
)


and there doesn't seem to be a way to call curves so that user can manually adjust, (even if the function had a parameter as INTERACTIVE or not i was never successful at calling INTERACTIVE )

_________________
TinT
My GIMP 2.10 plug-in writer Fiverr Gig
Plaid Community Forum
Imageplaid-patterns.com


Top
 Post subject: Re: Script interact with user
PostPosted: Mon Dec 28, 2015 5:33 am  (#3) 
Offline
New Member

Joined: Dec 27, 2015
Posts: 3
Thank you. This is a good solution to the problem. Though single solution.


Top
 Post subject: Re: Script interact with user
PostPosted: Mon Dec 28, 2015 6:36 am  (#4) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16023
I wonder if the GIMP devs would consider adding the RUN-INTERACTIVE RUN NONINTERACTIVE parameters to this PDB procedure? It would be nice to be able to call it INTERACTIVE within a script. Seems it wouldn't be too hard to add the parameter to the c file before compile.
static const GimpParamDef set_args[] =
{
  { GIMP_PDB_INT32,  "run-mode",     "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }"     },


For the life of me i can't find the curves file c src though. :puzzled

_________________
Image


Top
 Post subject: Re: Script interact with user
PostPosted: Mon Dec 28, 2015 7:02 am  (#5) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16023
You could if you wish call it with pre loaded vectors.

        ;;begin curves points array
        (gimp-curves-spline drawable HISTOGRAM-VALUE 14 (list->vector '(0 0 13 62 69 74 100 120 168 144 185 221 255 255)))

_________________
Image


Top
 Post subject: Re: Script interact with user
PostPosted: Mon Dec 28, 2015 12:30 pm  (#6) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
There are basically three types of filters that can affect a GIMP image: tools, plug-ins, and scripts. Tools can only be run interactively from either the Toolbox or the Menus -- it is not possible for a script or plug-in to run a tool interactively.

Plug-ins can be run interactively from other plug-ins or from scripts, though it is somewhat rare for this to happen (Difference Clouds is one script that does it).

Scripts can only be run interactively from plug-ins -- a script can NOT run another script interactively. (And I have never encountered a script being run interactively from a plug-in.)

-----------------------
When I have a sequence of actions that I wish to run repeatedly but that require execution of interactive operations, I find it useful to assign keyboard shortcuts to each of the actions. For your example, I would assign the following keys:
  1. Invert
  2. Rotate
  3. Crop
  4. Levels
The sequence can then be easily executed by pressing the keys in order (and providing the intermediate interactive input as necessary).

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Script interact with user
PostPosted: Tue Dec 29, 2015 5:26 pm  (#7) 
Offline
New Member

Joined: Dec 27, 2015
Posts: 3
Yes, i do like this (execute sequence by keyboard), not by hotkeys, but by menu quick access keys:
1) Alt+c v -- invert
2) Alt+i t c -- rotate (or 'w' or '1')
3) Alt+c c -- curves (or 'l' for levels)
but would optimize process. Anyway, exercises in the script-fu have benefited. Even partial automation greatly helped. Thank you all for explanations.


Top
 Post subject: Re: Script interact with user
PostPosted: Sun Jan 03, 2016 1:18 pm  (#8) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
It should also be possible to use an image parasite as persistent storage to track the state of actions.

If you want a script that does A,B,C in order every time, use the persistent storage to track which state was just completed, and then perform the next action, and do nothing if the last action

Not near a computer to test, however....

-Rob A>

_________________
Image
Fantasy Cartography and Mapping by RobA


Top
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group