It is currently Mon Jul 22, 2024 4:25 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Autocrop all layers
PostPosted: Tue Jun 07, 2011 10:54 am  (#21) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
Rod wrote:
AWESOME works perfect ofnuts! Even with 4 layers of content they autocrop very nicely. :)
Besides the Hello script that has got to be the smallest Python script i have seen to date.

Could you tell me how to edit the script if i wanted all the layers to become unlinked after the cropping takes effect?

Python can be quite terse, and the object classes defined by the python-fu interface are well done. I've yet to find a real-life case where Scheme is more suitable than Python for Gimp scripts.

For your request, just add the line "layer.linked=False" as below. Pay attention to the indenting, python is very fussy, indenting should be consistent (tabs and spaces are different, and I use tabs).

def autocropLinkedLayers(image,drawable):
   for layer in image.layers:
      if layer.linked:
         print 'Autocropping layer %s' % layer.name
         pdb.gimp_image_set_active_layer(image, layer)
         pdb.plug_in_autocrop_layer(image, layer)
         layer.linked=False

_________________
Image


Top
 Post subject: Re: Autocrop all layers
PostPosted: Tue Jun 07, 2011 11:37 am  (#22) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
I reckon it should be even shorter :)

Does the print statement produce any output on Linux? because on Windows it doesn't produce visible output anywhere and caused errors in your random-ellipses script: viewtopic.php?f=9&t=1790

The only advantage Scheme has over Python is that everyone with GIMP has it and doesn't need to install additional software.

Kevin


Top
 Post subject: Re: Autocrop all layers
PostPosted: Tue Jun 07, 2011 12:30 pm  (#23) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
The print statement shows output in a terminal session if you started Gimp that way, and likely in gimp-console. Otherwise it's ignored. This is not the gimp_message() that produces a error message box that has to be acknowledged by the user.

_________________
Image


Top
 Post subject: Re: Autocrop all layers
PostPosted: Tue Jun 07, 2011 12:32 pm  (#24) 
Offline
GimpChat Member
User avatar

Joined: Oct 29, 2010
Posts: 711
Location: Netherlands
@paynejk,
Linux can't run w/o python.
It's used extensively.
Gerard.

_________________
Gentoo Linux always up-to-date.
Kernel-3.17.4 Python-2.7.8/3.3.5
Gimp-2.8.14

I use Linux only.
And Virtualbox with Win 7


Top
 Post subject: Re: Autocrop all layers
PostPosted: Tue Jun 07, 2011 1:33 pm  (#25) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
Yeah it's us poor windows users that must suffer :lol
ofnuts i added the line and the splash screen shows it loading then no menu item.
I can live with just hitting shift and unlink.I probably indented the line incorrectly.
Thanks for the script you produced though it will save me loads of time. :)

_________________
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: Autocrop all layers
PostPosted: Tue Jun 07, 2011 2:48 pm  (#26) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
@Rod
You probably need to know that ofnuts uses tab characters to do his indenting rather than space characters and tabs are interpreted differently (and displayed differently in various editors)


Top
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Layers

2

No new posts Help with masks and layers please!

3

No new posts Attachment(s) Wrap all layers

4

No new posts G'mic animation help - static layers

3

No new posts Batch Create Layers

2



* Login  



Powered by phpBB3 © phpBB Group