You are here

Image 'test_pic.jpg' (1) is of type 'rgb', but an image of type 'gray' is expected

Hey guys,

I'm getting a weird error running a script-fu script from the command line:

GIMP-Error: Calling error for procedure 'gimp-image-add-layer':
Image 'test_pic.jpg' (1) is of type 'rgb', but an image of type 'gray' is expected

I am trying to use the Comic-Book-1 script in the registry. I've written a wrapper function around it that takes in a filename instead of an image object so I can call it from the command line. I'm not sure why I am getting this error because I don't see anything that is explicitly asking for a grayscale image.

Any tips would be much appreciated!!

-----------------------------------------------

THE WRAPPER:

(define (comic-book-cl filename)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(script-fu-Comic-Book1 RUN-NONINTERACTIVE
image drawable)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))

--------------------------------------------------

THE ACTUAL PLUGIN SCRIPT:

(define (script-fu-Comic-Book1
img
drawable
)

(gimp-undo-push-group-start img)

(let* (
(width (car (gimp-drawable-width drawable)))
(height (car (gimp-drawable-height drawable)))
(old-selection (car (gimp-selection-save img)))
(image-type (car (gimp-image-base-type img)))
(layer-type (car (gimp-drawable-type drawable)))
(layer-temp1 (car (gimp-layer-new img width height layer-type "temp1" 100 NORMAL-MODE)))
(layer-temp2 (car (gimp-layer-new img width height layer-type "temp2" 100 NORMAL-MODE)))
(layer-temp3 (car (gimp-layer-new img width height layer-type "temp3" 100 NORMAL-MODE)))
)

(if (eqv? (car (gimp-selection-is-empty img)) TRUE)
(gimp-drawable-fill old-selection WHITE-IMAGE-FILL)) ; so Empty and All are the same.
(gimp-selection-none img)
(gimp-image-add-layer img layer-temp1 -1)
(gimp-image-add-layer img layer-temp3 -1)
(gimp-image-add-layer img layer-temp2 -1)
(gimp-edit-copy drawable)
(gimp-floating-sel-anchor (car (gimp-edit-paste layer-temp1 0)))
(gimp-edit-copy layer-temp1)
(gimp-floating-sel-anchor (car (gimp-edit-paste layer-temp2 0)))
(gimp-edit-copy layer-temp1)
(gimp-floating-sel-anchor (car (gimp-edit-paste layer-temp3 0)))

(plug-in-photocopy 1 img layer-temp2 8.0 1.0 0.0 0.8)
(plug-in-photocopy 1 img layer-temp3 24.54 1.0 0.0 0.8)
(gimp-levels layer-temp2 0 215 235 1.0 0 255)
(gimp-levels layer-temp3 0 123 212 .44 0 255)
(gimp-layer-set-mode layer-temp2 3)
(gimp-layer-set-mode layer-temp3 3)
(gimp-levels layer-temp1 0 60 220 1.00 0 255)
(gimp-levels layer-temp1 0 25 225 2.25 0 255)
(plug-in-newsprint 1 img layer-temp1 3 0 0 0 0 15 0 75 0 0 0 2)
(gimp-image-merge-down img layer-temp3 0)
(gimp-image-merge-down img layer-temp2 0)

(set! layer-temp1 (car (gimp-image-get-active-layer img)))

(gimp-selection-load old-selection)
(gimp-selection-invert img)
(if (eqv? (car (gimp-selection-is-empty img)) FALSE) ; both Empty and All are denied
(begin
(gimp-edit-clear layer-temp1)
))

(gimp-layer-set-name layer-temp1 "Comic-Book")
(gimp-selection-load old-selection)
(gimp-image-remove-channel img old-selection)

(gimp-undo-push-group-end img)
(gimp-displays-flush)
)
)

(script-fu-register
"script-fu-Comic-Book1"
_"/Filters/Artistic/Comic-Book1..."
"Creates a Comic Book Effect."
"Joe Kitella "
"Joe Kitella"
"2009, May"
"RGB* GRAY*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)

Your problem comes because of this line:
(script-fu-Comic-Book1 RUN-NONINTERACTIVE image drawable)

script-fu automatically assumes the RUN-NONINTERACTIVE flag, so you shouldn't include it. What's happening is that the ComicBook1 script is taking the value of RUN-NONINTERACTIVE as the image id which, by accident, are both =0, but then it's taking the image id you're passing in as the drawable id, which isn't working.

Subscribe to Comments for "Image 'test_pic.jpg' (1) is of type 'rgb', but an image of type 'gray' is expected"