Is it possible to replicate the levels tool's white/black point picker in a script?

I’m trying to automate colour corrections so that by putting one sample-point at the white spot and another at the black spot, then calling a script. This is to get round the fact that the automatic white balance tool is too hit-and-miss for my photos.

At the moment I’m doing the corrections with a hacked version of the old Whitebalance script from Luca de Alfaro, but that is slow and processor-intensive. If I use the white/black point pickers in the levels tool manually, I get the same result, but it’s a real faff to do it with the picker when compared to using sample-points.

So what I’d like to do is apply these black/white point pickers from within my script. So far I can get the colour and position of the sample points with:

(samplePoint (car (gimp-image-find-next-sample-point image 0)))
(x (car (gimp-image-get-sample-point-position image samplePoint)))
(y (cadr (gimp-image-get-sample-point-position image Sampleoint)))
(fg (car (gimp-image-pick-color image drawable x y TRUE TRUE 1)))

But I’ve completely failed to find a way to then replicate the effect of clicking on that point with the relevant picker to my chosen spots. Is this possible or am I just being excessively optimistic?

As replied elswhere you are excessively optimistic. Scripts have no access to mouse clicks.

1 Like

As said, Scripts can’t get mouseclicks or get other user-input than through its interface.

What I had used at times to workaround that limitation is abusing the path tool and pick the last nodes placed in the active path. As those can be added by simple clicking, this sometimes work, if properly documented.

Another thing feasible, but them you have to build a plug-in in either C or Python is to have a custom built GTK interface, so that you can poll GIMP at reasonable intervals and check if new nodes to the active path have been added, allowing some kind of live interactivity to the plug-in.

Tini-fu however can only generate scripts with the generated interface, and run after the user submit all parameters, closing the window.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.