It is currently Sat Apr 20, 2024 5:58 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: script-fu: adding a layer from selection (2.7.5)
PostPosted: Wed Feb 29, 2012 9:43 am  (#1) 
Offline
GimpChat Member

Joined: Feb 22, 2012
Posts: 295
Location: Germany
Hi all.

I often need a new layer from my current selection.
There is a way: copy selection, paste selection and make a layer from floating selection.
It was not funny to do this always manually, so I wrote a script for it.
It does nothing else but automating the manual steps.
Originally the script was in Python, but there is an (already fixed) Error in the plugin-management
in the gimp source, so I ported it to script-fu, because everybody has the
script-fu funcionality in Gimp, but not alwas python.

The script deals with layer groups in Gimp 2.7.5 so it is not functional in Gimp 2.6.xx

Greets
Hatti


Attachments:
selectiontolayer.scm [2.21 KiB]
Downloaded 317 times


Last edited by Onkel Hatti on Fri Mar 02, 2012 12:16 am, edited 3 times in total.
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: script-fu: adding a layer from selection (2.7.5)
PostPosted: Wed Feb 29, 2012 3:13 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4736
What is the benefit over Ctrl-C/Ctrl-V/Crl-Shift-N (5 key presses: Ctrl-C-V-Shift-N)?

_________________
Image


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Wed Feb 29, 2012 3:30 pm  (#3) 
Offline
GimpChat Member

Joined: Feb 22, 2012
Posts: 295
Location: Germany
Benefit: just one mouseclick againt 5 keystrokes. I always make my selection by mouse. So I don't need to leave the mouse.
second benefit: The layer is added just over the layer, that the selection contains. Also within layer groups.
More benefits: no.

Hatti


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Wed Feb 29, 2012 7:49 pm  (#4) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
Not 5 but 2 keystrokes

Copy Ctrl-C
Paste as/ new layer What you wish

is true that Paste as/new layer has not a keystroke as default... but you may assign one

_________________
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: script-fu: adding a layer from selection (2.7.5)
PostPosted: Wed Feb 29, 2012 9:33 pm  (#5) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
PhotoComix wrote:
Not 5 but 2 keystrokes

Copy Ctrl-C
Paste as/ new layer What you wish

Paste As->New Layer places the new layer in the upper-left corner of the image, Onkei's script retains the layer's original offsets.

@Onkei, thanks for sharing your script. It seems very well written. The only change I might suggest would be to set the menu constraint parameter (the empty string after the date) in your register block to "*"; an asterisk will accept any kind of image but if there is no image open then the menu command will be grayed out. The empty string means that the menu command is available even if no image is open (useful for scripts that create new images or modify resources such as patterns or brushes).

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Wed Feb 29, 2012 10:56 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Thanks Onkei. :)

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Thu Mar 01, 2012 1:19 am  (#7) 
Offline
GimpChat Member

Joined: Feb 22, 2012
Posts: 295
Location: Germany
saulgoode wrote:
The only change I might suggest would be to set the menu constraint parameter (the empty string after the date) in your register block to "*"; an asterisk will accept any kind of image but if there is no image open then the menu command will be grayed out. The empty string means that the menu command is available even if no image is open (useful for scripts that create new images or modify resources such as patterns or brushes).


Done. Thanks.

By the way: The last char of my name is not an i, but an l, it means 'uncle' in german :-)

Hatti


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Thu Mar 01, 2012 1:40 am  (#8) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Onkel Hatti would you be able to do a 2.6 version. :)

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


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Thu Mar 01, 2012 5:48 am  (#9) 
Offline
GimpChat Member

Joined: Feb 22, 2012
Posts: 295
Location: Germany
Hi

Yes - attached...
There are some limitations.

Gimp 2.6.xx has no layer groups. So the layer group funktionality is not there... of course.
I see no way to reorder layers. So the newly created layer will always be the most upper
in the layer stack.
Gimp 2.7.5 has a buildtin command to reorder layers even within layer groups.

Hatti


Attachments:
selectiontolayer2.6.scm [2.02 KiB]
Downloaded 156 times


Last edited by Onkel Hatti on Thu Mar 01, 2012 12:38 pm, edited 1 time in total.
Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Thu Mar 01, 2012 6:22 am  (#10) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Onkel Hatti wrote:
I see no way to reorder layers. So the newly created layer will always be the most upper in the layer stack.

If you add the following code just after you convert your floating selection to a layer, the new layer will be lowered until it is just above 'inLayer'.

(let loop ((pos (pred (car (gimp-image-get-layer-position image inLayer)))))
  (unless (zero? pos)
    (gimp-image-lower-layer image newlayer)
    (loop (pred pos)) ))
(The 'pred' function simply subtracts one from its argument.)

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Thu Mar 01, 2012 12:39 pm  (#11) 
Offline
GimpChat Member

Joined: Feb 22, 2012
Posts: 295
Location: Germany
Thanks a lot, saulgoode.

I have added the lines. Great.

Hatti


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Thu Mar 01, 2012 6:16 pm  (#12) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Thank You Onkel Hatti 2.6 will be here for a long time, while we wait for 2.8

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


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Thu Mar 01, 2012 6:27 pm  (#13) 
Offline
GimpChat Member

Joined: Jun 04, 2011
Posts: 80
Graechan wrote:
Thank You Onkel Hatti 2.6 will be here for a long time, while we wait for 2.8


and even after for the less adventurous.


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Thu Mar 01, 2012 6:41 pm  (#14) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Yes i am quite sure i will be keeping Gimp-2.6.11 src around even after Gimp-2.8 arrives. :lol

My apologies for miss spelling your name Onkel Hatti. :)
Thanks for making this available for Gimp-2.6 version.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Thu Mar 01, 2012 10:25 pm  (#15) 
Offline
GimpChat Member

Joined: Jul 11, 2010
Posts: 349
I can find the link for the 2.6 version, but not the 2.76


Top
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Adding a image as a layer, moving layer, and then flattening

2

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

7

No new posts Attachment(s) Apply Selection to Layer with LIVE PREVIEW

6

No new posts Attachment(s) GEGL selection modification filter to apply on layer mask

8

No new posts Selection pasting only transparency - single layer image [Solved]

3



* Login  



Powered by phpBB3 © phpBB Group