Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Way to script manual rectangle definition?
#1
I want my script to have the user use the mouse to define a rectangle, then the script continues. It's less good to make my user create a rectangular selection, then start the script.
I am trying to avoid the situation where the user must
    start script A
    use the rectangle tool/shortcut to get a selection
    start script B to convert selection into rectangle and continue.
Is there a way to do this?
 
Basically, I have a large number of full length portraits with many different poses. Each portrait needs to be hand-cropped into a Square bust portrait. I've figured out most everything except how to tell the GIMP: "Here, the user defines a rectangle with the mouse."

I'm using GIMP 2.10.2, and python scripting, on Linux and Windows.

Thanks!
Reply
#2
You cannot have a GUI interaction  in a script. Typically you would ask the user to define the rectangle before calling your script.

If you have to process many pictures in sequence, you can do this:

  1. load the first image and do the initial processing
  2. let the user define the square
  3. run a second script that:
    • does the second part of the process
    • saves/exports the image
    • loads the next image and does the initial processing
  4. go to step 2
Then the script #1 is run once, and script #2 is run once for each image: except for the first, you have only one interaction per image. For an example see my ofn-file-next script.
Reply
#3
Just a thought, the gmic plugin could be a workaround, although if more convenient than making a selection then invoking a script is debatable.

The regular frame filter, with the frame settings zero'd will crop an image with a preview.

screenshot: https://i.imgur.com/rDmwk4b.jpg

and of course those settings can be saved for the next image. Percentage sliders? Depends how accurate you want to be.
Reply


Forum Jump: