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