Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
changing active layers
#7
(01-30-2023, 01:35 PM)salamander017 Wrote:
(01-29-2023, 09:10 PM)Ofnuts Wrote: You don't need to set active layers...  The layer argument of the (plugin-exchange) is the layer on which it will act, so this should be layer1 or layer2.

Otherwise, without changing colors, if you change the top layer to Difference blend mode, you will get white spots where the layers differ.

Oh, thank you very much for that. I have modified the code based on your suggestion. But now, when running the script, a dialog pops up and makes me choose between the layers.
But I prefer if it did not.
If I choose the top layer, only the blue to the top is applied. If I choose the bottom layer, all is applied correctly. (the top layer must be active)
When the active layer is the second layer. The colors are reversed and multiply is applied to the bottom layer instead.

(define (script-fu-gimpcompare image layer1 layer2)
  (plug-in-exchange RUN-NONINTERACTIVE image layer1 0 0 0 0 0 255 0 0 0)
  (plug-in-exchange RUN-NONINTERACTIVE image layer2 0 0 0 255 0 0 0 0 0)
  (gimp-layer-set-mode layer1 LAYER-MODE-MULTIPLY)
  (gimp-displays-flush)
)

(script-fu-register 
  "script-fu-gimpcompare"
  "<Image>/Script-Fu/gimpcompare"
  "blue red multiply"
  "Test"
  "Test"
  "2022"
  "RGB*"
  SF-IMAGE "Image" 0
  SF-DRAWABLE "layer1" 0
  SF-DRAWABLE "layer2" 0

)
I didn't say to use layers as explicit parameters to the script. Of course, when you do do, layer1 is implicitly the active layer ("drawable"(*),actually) in the image, but Gimp can't tell what layer2 should be so you get the dialog.

What I said is that (plug-in-exchange) doesn't run on the active drawable but on the drawable that you pass in its arguments.So you can take any layer of the image and give it to (plug-in-exchange) without making it active first.

So, if you remove your two SF_DRAWABLE, given just the image, you can get a list of its layers ((gimp-image_get-layers)) and then extract each of the two layers from that list and pass it to (plug-in-exchange).

(*) A "drawable" is anything you can paint on: layer, but also mask or channel. Or a layer group, on which you can't paint.
Reply


Messages In This Thread
changing active layers - by salamander017 - 01-29-2023, 06:54 AM
RE: changing active layers - by programmer_ceds - 01-29-2023, 10:57 AM
RE: changing active layers - by salamander017 - 01-29-2023, 12:47 PM
RE: changing active layers - by programmer_ceds - 01-29-2023, 05:25 PM
RE: changing active layers - by salamander017 - 01-30-2023, 01:35 PM
RE: changing active layers - by Ofnuts - 01-31-2023, 11:25 AM
RE: changing active layers - by salamander017 - 02-01-2023, 09:35 AM
RE: changing active layers - by programmer_ceds - 02-01-2023, 09:54 AM
RE: changing active layers - by salamander017 - 02-01-2023, 10:40 AM
RE: changing active layers - by Ofnuts - 01-29-2023, 09:10 PM

Forum Jump: