01-31-2023, 11:25 AM
(01-30-2023, 01:35 PM)salamander017 Wrote: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.(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
)
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.