01-29-2023, 05:25 PM
(01-29-2023, 12:47 PM)salamander017 Wrote:I think that the problem is that gimp-image-get-layers returns two parameters - the first is the number of layers and the second is an int32 array of the layer IDS (see the description of gimp-image-get-layers in the PDB browser).(01-29-2023, 10:57 AM)programmer_ceds Wrote: It might help if you gave details of the error message.
Hello, thank you for your time.
Regarding that, the error says:
GIMP Error
Execution error for 'Set active layers':
Error: Invalid type for argument 2 to gimp-image-set-active-layer
So your code is assigning the number of layers to layer1, not the ID of the first layer.
Try replacing the assignments that set layer1 and layer2 with:
(num_layers (cad (gimp-image-get-layers image)))
(layers (cadr (gimp-image-get-layers image)))
then:
(layer1 (aref layers 0))
(layer2 (aref layers 1))
However, it would be better code to set layer1 and layer2 (using the set! statement) after your let* statement - having checked that the image does actually have 2 (or possibly, depending on your needs) at least 2 layers before proceeding - report an error if there are not 2 layers, then your script can fail gracefully if it activated with just the one layer.