It is currently Sun Jul 21, 2024 10:19 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: How to delete a layer in script-fu
PostPosted: Tue May 31, 2011 9:22 pm  (#1) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
I have been left with these layers.

Image

And I'd like to delete the "Brouillard uni" layer before displaying the image with (gimp-display-new img)
Could somebody help me with the correct procedure as Wilbur does not like anything I have tried.

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Tue May 31, 2011 9:27 pm  (#2) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
Have you tried gimp-image-remove-layer?

(gimp-image-remove-layer img layer_name)

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Tue May 31, 2011 9:36 pm  (#3) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
i am looking the PB from gimp 2.7.3.
it says that "gimp-layer-delete" is deprecated and to use instead " gimp-item-delete" that has as argoment the id of the "item"

EDIT
Ninja posted, but Gnu-Tux should know better and anyway better 2 options then none :mrgreen:

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Tue May 31, 2011 10:28 pm  (#4) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
I tried (gimp-image-remove-layer img "Brouillard uni") but wilber said invalid type to argument 2

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Tue May 31, 2011 10:30 pm  (#5) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
The standard method of deleting a layer doesn't work?

Image

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Tue May 31, 2011 10:43 pm  (#6) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
Graechan wrote:
I tried (gimp-image-remove-layer img "Brouillard uni") but wilber said invalid type to argument 2

You need to use the pointer variable name (let* statement) you defined in the script , rather than the textual name in your layers dialog. You may have to save it so you can point back to it later and delete it.

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Tue May 31, 2011 10:49 pm  (#7) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
@ O
Graechan is asking how delete a layer in a script-fu

@Graechan
because bruillard uni is the layer name but not the layer ID
I didn't like much script fu also for this type of obstacles, ...you cannot just order to delete the "top" or, the "bottom" layer or the active layer...first you have to recover the ID assigned by gimp to the layer...that has no relation with the layer name


But..sorry i forgot how to, i only remember that was explained in one of the script fu tutorial by FencePost on http://www.gimpdome.com

@Gnu Tux
Ninja posted again ! :lol
Still i believe the layer name passed as paramether instead then the layer ID remain a problem

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Wed Jun 01, 2011 12:38 am  (#8) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Fencepost wrote of using the "car" command to assign a layer ID so I tried this.

(set! activelayer (car (gimp-image-set-active-layer img "Brouillard uni")))

But i still get the same error on this command

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Wed Jun 01, 2011 12:49 am  (#9) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
PhotoComix wrote:
@ O
Graechan is asking how delete a layer in a script-fu
:oops: Oh, my, how embarrassing. Forget I did that. Sheesh!

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Wed Jun 01, 2011 12:51 am  (#10) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
Layer IDs are like definition variables (no quotes). Look at the define variables, and then look at the let* statements. You'll see layers being referred to things like:

text-layer

In this case, GnuTux pointed out that there is a let* statement that defines this layer and he suggested you use the procedure he recommends with that layer variable not the layer name. Make sense?

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Last edited by mahvin on Wed Jun 01, 2011 1:32 am, edited 1 time in total.

Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Wed Jun 01, 2011 1:22 am  (#11) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
TA-DA

I got it


I had previously assigned "brouillard uni" as "activelayer" in the Let block all I needed was (gimp-image-remove-layer img activelayer). which did not occur to me because Frame 9 was the active layer.
Thanks for prodding me Mahvin

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Wed Jun 01, 2011 1:30 am  (#12) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there

Agh I got Ninja'd..... :) But here's what I was writing any way ...

The delete procedure will be expecting an id number not a string, so you need to find the id of the "Brouillard uni" layer. Here's some code I wrote as part of someone else's problem that finds a layer id based on it's name:

; routine to find the Id of a layer given the layer name
(define (kp24_find_layer_by_name image layerName)
  (let* (
           (layerList (vector->list (cadr (gimp-image-get-layers image))))    ; get the list of layer ids
           (wantedLayerId -1)
           (layerText "")
        )
       
        (for-each
          (lambda (layerId)
            (set! layerText (car (gimp-drawable-get-name layerId))) ; get a layer name
            (if (string=? layerText layerName)   ; is it the one we want?
              (set! wantedLayerId layerId)       ; it is, so save the layer id
            )           
          )
          layerList
        )
        (if (= -1 wantedLayerId)      ; didn't find it so complain
          (error (string-append "Could not find a layer with name:- " layerName))
        )
        (list wantedLayerId)
  )
)


to use it you pass it the image id and the string that is name of your layer. It returns a list containing the id of the layer:

   (set! wanted_layer_id (car (kp24_find_layer_by_name imageId "Brouillard uni")))
   (gimp-drawable-delete wanted_layer_id)


Kevin


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Wed Jun 01, 2011 1:34 am  (#13) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
I don't use script-fu, but another possibility is to iterate the layers and delete those with a name that match "Frame*" (or whatever regexp will work in TinyScheme). Personally, I make a habit of calling my temporary work items (layers, gradients, brushes...) with a "#" so that they are easier to spot.

In python-fu you have an <Image> object, that has an array of <Layer> (unexpectedly called "layers"), ordered as in the layer stack, so the top layer is image.layers[0]. Welcome to the 21st century :)

PS: sorta ninja'd by paynejk myself :)

_________________
Image


Top
 Post subject: Re: How to delete a layer in script-fu
PostPosted: Wed Jun 01, 2011 3:25 am  (#14) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
thank you Kevin I noted all that in case I need in future. And Offnuts its evident I don't do script-fu either :hehe

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts How do I script a new white layer to the bottom of the layer stack

7

No new posts How to delete account

2

No new posts Attachment(s) [SOLVED] Delete large part of path?

4

No new posts script to load text file and create text layer

6



* Login  



Powered by phpBB3 © phpBB Group