Gimp-Forum.net
Where Do I Even Start? - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Where Do I Even Start? (/Thread-Where-Do-I-Even-Start)



Where Do I Even Start? - JustaBill - 06-02-2020

Hello Everyone,

First post.  I'm using the GIMP 2.10.14 on macOS Sierra.  I'm not sure if it's worth the effort, but I'm trying to create a script to perform 3 or 4 menu functions on a PNG file once I've opened it.  I have a LOT of files to process, but I'd prefer not to use any sort of batch mode.  I need to see each file to make sure it doesn't need any additional work.

Below are the commands I need to script and the Script-Fu procedures I think I could use.


Brightness-Contrast
  • Been using Colors, Brightness-Contrast...
  • Found (gimp-drawable-brightness-contrast drawable brightness contrast)

Sharpen
  • Been using Filters, Enhance, Sharpen (Unsharp Mask...)
  • Found (plug-in-unsharp-mask run-mode image drawable radius amount threshold)

Posterize
  • Been using Colors, Posterize...
  • Found (gimp-drawable-posterize drawable levels)

I do those same three operations with the same settings on every file.  It ought to be as simple as dumping those three lines into a file with the numerical values filled in and pressing play.  It's not.

The procedures won't work because "drawable" is undefined.  I'm sure everyone reading this will know what drawable is, but Google and I don't.  Is it the file name?  How do I capture that and transfer it into each function?


Thanks,
Bill


RE: Where Do I Even Start? - Ofnuts - 06-02-2020

A "drawable" is something that you can draw on: layer, layer mask, or channel.  

In most cases, the first two parameters that you define when you register are 1) the image and 2) the drawable (and in some cases, they are there by default).

If you define your script/plugin to take two (or more) parameters, when it is called the image is the first and the drawable is the second. That drawable is whatever the active drawable of that image is for Gimp when you use the menu: usually he active layer, but it can be a layer mask or a channel if you are editing such.

PS: you can also write scripts/plugins in Python.


RE: Where Do I Even Start? - rich2005 - 06-03-2020

One problem is the filters you want to use are now GEGL operations. Not normally scriptable. While it is now possible to use these via a python - script-fu combination see: https://www.gimp-forum.net/Thread-Scripting-GEGL-operations It is going to be a lot of work on your part, up to you. Works with Windows & linux, not sure about MacOS

One disadvantage is losing the benefit of GEGL on canvas editing. Adjust a script, nothing happens until you apply the script.

One possibility is use Filters -> Generic -> GEGL graph...
Make a 'boilerplate' text file of the commands and values required, copy / paste into Gimp. Nowhere near as convenient as a nice interface with sliders for adjustment but it is possible to edit in 'real-time' example https://i.imgur.com/Jw042O8.mp4 (hmm..that Eeek is a syntax change between Gimp 2.10.10 and 2.10.14 )

Where to find details of the GEGL filters http://gegl.org/operations/ and the ones I used in the demo (all default values)

Code:
brightness-contrast contrast=1.0  brightness=0.0
unsharp-mask std-dev=3 scale=0.5 threshold=0.0
posterize levels=3



RE: Where Do I Even Start? - JustaBill - 06-03-2020

The GEGL graph option looks very good for what I'm trying to do.  Nice and quick and simple.  Thank you.

I notice the default pipeline text is gaussian-blur std-dev-x=0.3rel std-dev-y=0.3rel.  Is that stored somewhere that it could be changed?  If not, I'll just keep pasting the commands I want, as you showed.  I set up a preset, but it's faster to just paste over what's there than it is to fiddle with the drop-down.

Thanks,
Bill