It is currently Sat May 18, 2013 6:41 am


Latest GIMP Scripts & Plug-ins

All times are UTC - 5 hours [ DST ]




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

Joined: Feb 22, 2012
Posts: 159
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 60 times


Last edited by Onkel Hatti on Fri Mar 02, 2012 1: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
 Profile  
 

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

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

_________________
Image


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

Joined: Feb 22, 2012
Posts: 159
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
 Profile  
 
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Wed Feb 29, 2012 8:49 pm  (#4) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 4957
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
 Profile  
 
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Wed Feb 29, 2012 10:33 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Apr 23, 2010
Posts: 814
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
 Profile  
 
 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Wed Feb 29, 2012 11:56 pm  (#6) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 8913
Location: "Looking for my eraser" =P
Thanks Onkei. :)

_________________
Image
Gimp Rocks Blog
Simply Gimp Tutorials
"Once your in the cloud, you're in the net"
____________
OK, . . . . so what's the speed of dark?


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

Joined: Feb 22, 2012
Posts: 159
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
 Profile  
 

 Post subject: Re: script-fu: adding a layer from selection (2.7.5)
PostPosted: Thu Mar 01, 2012 2:40 am  (#8) 
Offline
Gimp Scripts Editor
User avatar

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

_________________
Image


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

Joined: Feb 22, 2012
Posts: 159
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 27 times


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

Joined: Apr 23, 2010
Posts: 814
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'.

Code:
(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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

* Login   * Subscribe to RSS Feed


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group