07-04-2025, 04:21 AM
Hi AgHornet,
Assuming you are on gimp 2.10 as your post says (so not gimp 3.0), hopefully the test script below helps. Example output:
Test get pixel Warning
Name: Background
Coordinate: 4 9
Bpp: 4
Do num-channels = bpp? #t
Is pixel a vector? #t
Is len pixel = bpp? #t
Channel: 0 Value: 152
Channel: 1 Value: 229
Channel: 2 Value: 84
Channel: 3 Value: 197
As for Image -> Image properties
...
Number of Channels
...
It's the number of selection mask channels in the mage. You can add these using the 'Create a new channel' icon at the bottom left of the channels dialog. See https://docs.gimp.org/2.10/en/gimp-channel-dialog.html
Assuming you are on gimp 2.10 as your post says (so not gimp 3.0), hopefully the test script below helps. Example output:
Test get pixel Warning
Name: Background
Coordinate: 4 9
Bpp: 4
Do num-channels = bpp? #t
Is pixel a vector? #t
Is len pixel = bpp? #t
Channel: 0 Value: 152
Channel: 1 Value: 229
Channel: 2 Value: 84
Channel: 3 Value: 197
As for Image -> Image properties
...
Number of Channels
...
It's the number of selection mask channels in the mage. You can add these using the 'Create a new channel' icon at the bottom left of the channels dialog. See https://docs.gimp.org/2.10/en/gimp-channel-dialog.html
Code:
(define (boolean->string b) (if b "#t" "#f"))
(define (script-fu-test-get-pixel image drawable x y)
(let* ((bpp (car (gimp-drawable-bpp drawable)))
(pixel-result (gimp-drawable-get-pixel drawable x y))
(num-channels (car pixel-result))
(pixel (cadr pixel-result))
(mess "")
)
(set! mess (string-append mess "Name: " (car (gimp-item-get-name drawable)) "\n"))
(set! mess (string-append mess "Coordinate: " (number->string x) " " (number->string y) "\n"))
(set! mess (string-append mess "Bpp: " (number->string bpp) "\n"))
(set! mess (string-append mess "Do num-channels = bpp? " (boolean->string (= num-channels bpp)) "\n"))
(set! mess (string-append mess "Is pixel a vector? " (boolean->string (vector? pixel)) "\n"))
(set! mess (string-append mess "Is len pixel = bpp? " (boolean->string (= (vector-length pixel) bpp)) "\n"))
(do ((len (vector-length pixel))
(i 0 (+ i 1)))
((= i len))
(set! mess (string-append mess "Channel: " (number->string i) " Value: " (number->string (vector-ref pixel i)) "\n"))
)
(gimp-message mess)
))
(script-fu-register
"script-fu-test-get-pixel" ; Name
"Test get pixel" ; Menu label
"" ; Description
"Author" ; Author
"Copyright" ; Copyright
"" ; Date
"*" ; Types
SF-IMAGE "image" 0
SF-DRAWABLE "drawable" 0
SF-ADJUSTMENT "x" (list 0 0 1000 1 10 0 SF-SPINNER)
SF-ADJUSTMENT "y" (list 0 0 1000 1 10 0 SF-SPINNER)
)
(script-fu-menu-register "script-fu-test-get-pixel" "<Image>/Script-Fu")