It is currently Mon May 20, 2013 1:17 pm


Latest GIMP Scripts & Plug-ins

All times are UTC - 5 hours [ DST ]




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

Joined: Oct 25, 2010
Posts: 1296
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).

Code:
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
 Profile  
 

 Post subject: Re: Autocrop all layers
PostPosted: Tue Jun 07, 2011 12:37 pm  (#22) 
Offline
Gimp Scripts Editor
User avatar

Joined: Jun 22, 2010
Posts: 581
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
 Profile  
 
 Post subject: Re: Autocrop all layers
PostPosted: Tue Jun 07, 2011 1:30 pm  (#23) 
Offline
GimpChat Member
User avatar

Joined: Oct 25, 2010
Posts: 1296
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
 Profile  
 
 Post subject: Re: Autocrop all layers
PostPosted: Tue Jun 07, 2011 1:32 pm  (#24) 
Offline
GimpChat Member
User avatar

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

_________________
Gentoo Linux always up-to-date.
Kernel-3.8.4 Python-2.7.3-r3
Gimp-2.8.4

I use Linux only.


Top
 Profile  
 
 Post subject: Re: Autocrop all layers
PostPosted: Tue Jun 07, 2011 2:33 pm  (#25) 
Online
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 8967
Location: "Looking for my eraser" =P
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
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: Autocrop all layers
PostPosted: Tue Jun 07, 2011 3:48 pm  (#26) 
Offline
Gimp Scripts Editor
User avatar

Joined: Jun 22, 2010
Posts: 581
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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: dinasset, Wallace and 4 guests


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