Question

I get the following error:

Error: Invalid type for argument 1 to gimp-layer-new

But as near as I can tell, "image" is still in scope when I run that function, and should be set to the return value of gimp-image-new, which is the correct type. All I want is a dumb little animated gif, and it's getting to the point where I could do these operations manually more quickly.

(begin
 (let*
      (
           (image (gimp-image-new 512 384 1))
           (counter 0)
      )

      (while (< counter 30)
           (let*
                (
                     (layer (gimp-layer-new image 512 384 2 (string-append (string-append "frame " (number->string counter)) " (33ms)") 100 0) )
                )

                (gimp-image-add-layer image layer -1)
                (plugin-in-rgb-noise 0 image layer 0 1 0.37 0)
                (plugin-in-rgb-noise 0 image layer 0 1 0.37 0)
                (gimp-brightness-contrast layer 0 -42)
                (plugin-in-rgb-noise 0 image layer 0 1 0.37 0)
                (plug-in-deinterlace 0 image layer 1)
           )
           (set! counter (+ counter 1))
      )
      (gimp-display-new image)
 )
)
Was it helpful?

Solution

Try this:

(begin
  (let* ((image (car (gimp-image-new 512 384 1))) ; here was the problem
         (counter 0))    
    (while (< counter 30)
           (let* ((layer
                   (gimp-layer-new
                    image 512 384 2
                    (string-append "frame " (number->string counter) " (33ms)")
                    100 0)))
             (gimp-image-add-layer image layer -1)
             (plugin-in-rgb-noise 0 image layer 0 1 0.37 0)
             (plugin-in-rgb-noise 0 image layer 0 1 0.37 0)
             (gimp-brightness-contrast layer 0 -42)
             (plugin-in-rgb-noise 0 image layer 0 1 0.37 0)
             (plug-in-deinterlace 0 image layer 1))
           (set! counter (+ counter 1)))
    (gimp-display-new image)))

I took the liberty of properly indenting your code and simplifying the string-append expression, but in essence the problem is that you have to take the car of the value returned by gimp-image-new, according to the example in this page, section 6. This will solve the Error: Invalid type for argument 1 to gimp-layer-new reported in the question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top