Thomas DuBuisson ( wrote:
> ------------- CODE --------------

(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE
                     "image.png" "image.png")))
       (layer0 (car (gimp-image-get-active-layer image)))
  (let* ((layer1 (car (gimp-image-flatten image))))
      (gimp-layer-set-mode layer1 25)
  (let* ((layer1 (car (gimp-layer-new-from-drawable layer0 image))))
> ----------------- END CODE --------------

As you already found out, flattening the image makes its layers invalid,
this is because it generates a new one, which it returns as result.

As you can see in my re-indented version of your code, you use let* to
bind the newly created layer to the "layer1" variable, yet you forget
it too early, since you need to use it for the

I don't like how you nest the various let*-statements. That makes the
code hard to track.

It would be better if you have some dummy variable declarations in your
outer let*-statement and then use set! to redefine the values. Something
like this:

(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE
                     "image.png" "image.png")))
       (layer0 (car (gimp-image-get-active-layer image)))
       (layer1 0)
  (set! layer0 (car (gimp-image-flatten image)))
  (gimp-layer-set-mode layer0 25)
  (set! layer1 (car (gimp-layer-new-from-drawable layer0 image)))

Also note that the use of "25" for the mode is not nice, you really
should use the symbolic constants.

> 3) C Assertation failures
> Perhaps most concerning are the assertation failures.  Presumably,
> these are not supposed to happen.  How concerned should I be?
> (gimp-console:2987): Gimp-Core-CRITICAL **: gimp_image_remove_layer:
> assertion `gimp_container_have (image->layers, GIMP_OBJECT (layer))'
> failed

You should be concerned moderately, since your code apparently is doing
some bogus stuff and does not properly keep track of the layers in the
image. However, the critical warning should not happen, we really should
catch these errors in the PDB wrappers already.

Hope this helps,
Gimp-user mailing list

Reply via email to