Yesterday, 03:51 PM
Anyone have any ideas?
Also, how is it possible that an RBG png image when opened in the GUI and image properties view, says it has 0 channels, but you can Go to Windows > Dockable Dialogs > Channels and select each of the 3 channels, np??
-----
**Bug Report Summary: gimp-drawable-get-pixel Returns UNEXPECTED_TYPE for Pixel Data Despite Channels Being Visible in UI**
**GIMP Version:** 2.10.38
**Operating System:** windows11
-----
**Description of Issue:**
When attempting to retrieve pixel data using the gimp-drawable-get-pixel PDB function within a Script-Fu plugin, the second return value (expected to be the GIMP_PDB_INT8ARRAY containing pixel bytes) is consistently an UNEXPECTED_TYPE from Script-Fu's perspective. This occurs even when the image clearly displays color channels in GIMP's UI.
**Detailed Observations:**
1. **Contradictory Channel Information:**
* Image > Image Properties for the affected image reports "Number of channels: 0".
* However, Windows > Dockable Dialogs > Channels *visibly shows* and allows interaction with R, G, and B channels (for an RGB image), and selecting/deselecting these channels correctly alters the image's display. This confirms that the channel data *does* exist internally and is usable by GIMP's UI.
2. **gimp-drawable-get-pixel Behavior:**
* The function call itself does not error out. It returns a Scheme PAIR (a two-element list) as expected.
* The first element of this pair (expected num-channels) appears to be accessible.
* The second element of this pair (expected pixel data, an INT8ARRAY or list of bytes) is the problem. Script-Fu's (cadr pixel-result) evaluates to a value that is not a list (empty or non-empty), boolean, number, string, or symbol. Our enhanced debugging in Script-Fu reports its type as UNEXPECTED_TYPE.
**Impact:**
This issue prevents Script-Fu plugins from reliably reading pixel data from images via gimp-drawable-get-pixel, effectively breaking any functionality that relies on pixel-level inspection (e.g., custom filters, image analysis, scene detection from masks).
**Steps to Reproduce:**
1. Open an RGB PNG image (e.g., scene_mask.png with visible white/black areas) in GIMP.
2. Verify the contradictory channel information:
* Go to Image > Image Properties and confirm "Number of channels: 0".
size in pixels: 7013 x 4062 pixels
Color space: RGB color: GIMP built-in sRGB
Precision: 8-bit gamma integer
File Type: PNG image
Number of pixels: 34798506
Number of layers: 1
Number of channels: 0
Number of Paths: 0
* Go to Windows > Dockable Dialogs > Channels and confirm that R, G, and B channels are visible and functional (e.g., toggling their visibility changes the image).
3. Load the Script-Fu plugin (with the relevant scan function snippet) into GIMP.
4. Run the Script-Fu plugin.
5. Observe the GIMP console or debug messages for output similar to:
script-fu.exe-Warning: Debug: Raw pixel-result at (X,Y): PAIR (Unknown Type)
script-fu.exe-Warning: Warning: pixel-bytes is not a valid list for pixel data at (X,Y). Raw value type: UNEXPECTED_TYPE Value: Cannot display raw value
**Expected Behavior:**
gimp-drawable-get-pixel should return a valid Scheme list of integer bytes (e.g., (255 255 255) for a white RGB pixel) as its second return value when invoked on a drawable from an image with visible and functional channels.
**Troubleshooting Performed (No Effect):**
* Attempted Image > Mode > Grayscale then Image > Mode > RGB.
* Attempted Image > Flatten Image and Image > Merge Visible Layers....
* Exported the image as a new PNG and then re-opened it in GIMP.
**Relevant Script-Fu Snippet (from scan function):**
scheme
(define (scan x y)
(let ((pixel-result (gimp-drawable-get-pixel mask-drawable x y)))
(gimp-message (string-append "Debug: Raw pixel-result at (" (number->string x) "," (number->string y) "): "
(if (pair? pixel-result) "PAIR" "NON-PAIR")
(if (and (not (pair? pixel-result)) (boolean? pixel-result)) (if pixel-result " (Value: TRUE)" " (Value: FALSE)")
(if (and (not (pair? pixel-result)) (number? pixel-result)) (string-append " (Value: " (number->string pixel-result) ")")
" (Unknown Type)"))))
(if (pair? pixel-result)
(let* (
(num-channels (car pixel-result))
(pixel-bytes (cadr pixel-result))
)
(if (and (pair? pixel-bytes) (not (null? pixel-bytes)))
(begin ; Process the pixel if valid
; ... (pixel processing logic) ...
)
(gimp-message (string-append "Warning: pixel-bytes is not a valid list for pixel data at (" (number->string x) "," (number->string y) "). Raw value type: "
(cond
((pair? pixel-bytes)
(if (null? pixel-bytes) "EMPTY_LIST ()" "NON_EMPTY_LIST"))
((boolean? pixel-bytes)
(if pixel-bytes "BOOLEAN_TRUE (#t)" "BOOLEAN_FALSE (#f)"))
((number? pixel-bytes) "NUMBER")
((symbol? pixel-bytes) "SYMBOL")
((string? pixel-bytes) "STRING")
(else "UNEXPECTED_TYPE"))
" Value: "
(cond
((boolean? pixel-bytes) (if pixel-bytes "#t" "#f"))
((number? pixel-bytes) (number->string pixel-bytes))
((pair? pixel-bytes) (if (null? pixel-bytes) "()" (string-append "(" (number->string (car pixel-bytes)) "...")) )
(else "Cannot display raw value")))))
)
(gimp-message (string-append "Error: gimp-drawable-get-pixel returned an unexpected value (not a pair) for pixel-result at (" (number->string x) "," (number->string y) "). Raw value: "
(if (boolean? pixel-result) (if pixel-result "TRUE" "FALSE") "Unknown type"))))
)
)
-----
Also, how is it possible that an RBG png image when opened in the GUI and image properties view, says it has 0 channels, but you can Go to Windows > Dockable Dialogs > Channels and select each of the 3 channels, np??
-----
**Bug Report Summary: gimp-drawable-get-pixel Returns UNEXPECTED_TYPE for Pixel Data Despite Channels Being Visible in UI**
**GIMP Version:** 2.10.38
**Operating System:** windows11
-----
**Description of Issue:**
When attempting to retrieve pixel data using the gimp-drawable-get-pixel PDB function within a Script-Fu plugin, the second return value (expected to be the GIMP_PDB_INT8ARRAY containing pixel bytes) is consistently an UNEXPECTED_TYPE from Script-Fu's perspective. This occurs even when the image clearly displays color channels in GIMP's UI.
**Detailed Observations:**
1. **Contradictory Channel Information:**
* Image > Image Properties for the affected image reports "Number of channels: 0".
* However, Windows > Dockable Dialogs > Channels *visibly shows* and allows interaction with R, G, and B channels (for an RGB image), and selecting/deselecting these channels correctly alters the image's display. This confirms that the channel data *does* exist internally and is usable by GIMP's UI.
2. **gimp-drawable-get-pixel Behavior:**
* The function call itself does not error out. It returns a Scheme PAIR (a two-element list) as expected.
* The first element of this pair (expected num-channels) appears to be accessible.
* The second element of this pair (expected pixel data, an INT8ARRAY or list of bytes) is the problem. Script-Fu's (cadr pixel-result) evaluates to a value that is not a list (empty or non-empty), boolean, number, string, or symbol. Our enhanced debugging in Script-Fu reports its type as UNEXPECTED_TYPE.
**Impact:**
This issue prevents Script-Fu plugins from reliably reading pixel data from images via gimp-drawable-get-pixel, effectively breaking any functionality that relies on pixel-level inspection (e.g., custom filters, image analysis, scene detection from masks).
**Steps to Reproduce:**
1. Open an RGB PNG image (e.g., scene_mask.png with visible white/black areas) in GIMP.
2. Verify the contradictory channel information:
* Go to Image > Image Properties and confirm "Number of channels: 0".
size in pixels: 7013 x 4062 pixels
Color space: RGB color: GIMP built-in sRGB
Precision: 8-bit gamma integer
File Type: PNG image
Number of pixels: 34798506
Number of layers: 1
Number of channels: 0
Number of Paths: 0
* Go to Windows > Dockable Dialogs > Channels and confirm that R, G, and B channels are visible and functional (e.g., toggling their visibility changes the image).
3. Load the Script-Fu plugin (with the relevant scan function snippet) into GIMP.
4. Run the Script-Fu plugin.
5. Observe the GIMP console or debug messages for output similar to:
script-fu.exe-Warning: Debug: Raw pixel-result at (X,Y): PAIR (Unknown Type)
script-fu.exe-Warning: Warning: pixel-bytes is not a valid list for pixel data at (X,Y). Raw value type: UNEXPECTED_TYPE Value: Cannot display raw value
**Expected Behavior:**
gimp-drawable-get-pixel should return a valid Scheme list of integer bytes (e.g., (255 255 255) for a white RGB pixel) as its second return value when invoked on a drawable from an image with visible and functional channels.
**Troubleshooting Performed (No Effect):**
* Attempted Image > Mode > Grayscale then Image > Mode > RGB.
* Attempted Image > Flatten Image and Image > Merge Visible Layers....
* Exported the image as a new PNG and then re-opened it in GIMP.
**Relevant Script-Fu Snippet (from scan function):**
scheme
(define (scan x y)
(let ((pixel-result (gimp-drawable-get-pixel mask-drawable x y)))
(gimp-message (string-append "Debug: Raw pixel-result at (" (number->string x) "," (number->string y) "): "
(if (pair? pixel-result) "PAIR" "NON-PAIR")
(if (and (not (pair? pixel-result)) (boolean? pixel-result)) (if pixel-result " (Value: TRUE)" " (Value: FALSE)")
(if (and (not (pair? pixel-result)) (number? pixel-result)) (string-append " (Value: " (number->string pixel-result) ")")
" (Unknown Type)"))))
(if (pair? pixel-result)
(let* (
(num-channels (car pixel-result))
(pixel-bytes (cadr pixel-result))
)
(if (and (pair? pixel-bytes) (not (null? pixel-bytes)))
(begin ; Process the pixel if valid
; ... (pixel processing logic) ...
)
(gimp-message (string-append "Warning: pixel-bytes is not a valid list for pixel data at (" (number->string x) "," (number->string y) "). Raw value type: "
(cond
((pair? pixel-bytes)
(if (null? pixel-bytes) "EMPTY_LIST ()" "NON_EMPTY_LIST"))
((boolean? pixel-bytes)
(if pixel-bytes "BOOLEAN_TRUE (#t)" "BOOLEAN_FALSE (#f)"))
((number? pixel-bytes) "NUMBER")
((symbol? pixel-bytes) "SYMBOL")
((string? pixel-bytes) "STRING")
(else "UNEXPECTED_TYPE"))
" Value: "
(cond
((boolean? pixel-bytes) (if pixel-bytes "#t" "#f"))
((number? pixel-bytes) (number->string pixel-bytes))
((pair? pixel-bytes) (if (null? pixel-bytes) "()" (string-append "(" (number->string (car pixel-bytes)) "...")) )
(else "Cannot display raw value")))))
)
(gimp-message (string-append "Error: gimp-drawable-get-pixel returned an unexpected value (not a pair) for pixel-result at (" (number->string x) "," (number->string y) "). Raw value: "
(if (boolean? pixel-result) (if pixel-result "TRUE" "FALSE") "Unknown type"))))
)
)
-----