Update 2: 1) Exceptions The macro (not sure of the underlying primitives) "catch" will catch errors. The web page didn't even call them exceptions, which explains why I/google didn't find it quickly.
Ex: when converting an image that might already be RGB to RGB: (catch (gimp-image-convert-rgb image)) 2) The layer issue As stated before, an earlier command was obliterating my layer and I forgot to take the head of the get-active-{layer,drawable} in my later operations. 3) Assertation failures and segfaults The assertation failures are probably somehow connected with my layer merging - not that it is good to be able to hit this so easily. I also found a segfault, do to out of range arguments, since my previous post and see that this doesn't crash the program - so its running in a different thread or processs I guess. Not sure if I can catch this with "catch", if I can't then I'll have to fix these corner cases. Perhaps I'll make some patches for the function documentation if people are interested. Thomas On Tue, Nov 24, 2009 at 11:34 AM, Thomas DuBuisson <thomas.dubuis...@gmail.com> wrote: > Update: > > 1) The question regarding exceptions remains - there are too many > corner cases, mostly undocumented, so it would be nice to ignore them > silently. > > 2) I see my fix was almost right but I forgot to take the head of the list: > "(car (gimp-image-get-active-drawable image))" is what I want, not the > no-longer-existing layer0 or the whole list returned by > gimp-image-get-active-{layer,drawable}. > > 3) I still get things like the message below, so same question. > (gimp-console:2987): Gimp-Core-CRITICAL **: gimp_image_remove_layer: > assertion `gimp_container_have (image->layers, GIMP_OBJECT (layer))' > failed > > > > On Tue, Nov 24, 2009 at 10:05 AM, Thomas DuBuisson > <thomas.dubuis...@gmail.com> wrote: >> Hello list, >> >> I am planning on evolving image transformations using an AST of the >> script-fu langauge and generating random (but syntatically correct) >> scripts. I would like to avoid programming in hundreds of corner >> cases into the system and thus have the following questions: >> >> 1) Script-fu throws exceptions >> >> If/when I do something basic like call "gimp-image-raise-layer" on a >> layer that can not be raised, an exception is thrown. I would very >> much like to catch/ignore exceptions such as this but it seems >> script-fu is too primitive. Am I missing something? >> >> 2) gimp-layer-new-from-drawable nearly always fails >> >> ------------- 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 -------------- >> >> In the above you see I define layer0 as the active layer (which I >> thought was a drawable) but this doesn't work for >> gimp-layer-new-from-drawable. Replacing layer0 with 'image' also >> doesn't work and most frustratingly, using " >> (gimp-image-get-active-drawable image)" also doesn't work - which I >> really thought it should based on the documentation. What does this >> function expect? >> >> (I understand gimp-image-flatten somehow screws everything up by >> eliminating the layer, but am still not clear how to once-again get a >> valid layer from my image) >> >> >> 3) C Assertation failures >> Perhaps most concerning are the assertation failures. Presumably, >> these are not supposed to happen. How concerned should I be? >> >> -------------------- START CONSOLE DUMP ------------------------- >>> (let* ((image (car (gimp-file-load RUN-NONINTERACTIVE "image.png" >>> "image.png"))) >> (layer0 (car (gimp-image-get-active-layer image)))) >> (let* ((layer1 (car (gimp-layer-new-from-drawable layer0 image)))) >> (gimp-layer-add-alpha layer1) >> (gimp-image-merge-down image layer1 2)) >> (set! layer0 (gimp-image-get-active-layer image)) >> (let* ((layer1 (car (gimp-image-flatten image)))) >> (gimp-layer-set-opacity layer1 21.811554) >> (gimp-image-merge-down image layer1 0)) >> (set! layer0 (gimp-image-get-active-layer image)) >> (let* ((layer1 (car (gimp-layer-new-from-drawable layer0 image)))) >> (gimp-layer-flatten layer1) >> (gimp-image-merge-down image layer1 0)) >> (set! layer0 (gimp-image-get-active-layer image)) >> (let* ((currDraw (car (gimp-image-get-active-layer image)))) >> (gimp-file-save RUN-NONINTERACTIVE image currDraw "newImage.png" >> "newImage.png" )) >> ) >> >> (gimp-console:2987): Gimp-Core-CRITICAL **: gimp_image_remove_layer: >> assertion `gimp_container_have (image->layers, GIMP_OBJECT (layer))' >> failed >> >> ---------------------------- END CONSOLE DUMP ------------------------- >> >> >> Cheers, >> Thomas >> > _______________________________________________ Gimp-user mailing list Gimp-user@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user