It is currently Mon Jul 22, 2024 2:21 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Autocrop all layers
PostPosted: Mon Jun 06, 2011 2:20 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
Can a script be written, or is there one available to autocrop all layers in an xcf file?
So many times it seems i create small selections that need to be rotated and a script to autocrop all those at once would be so time saving.
If it could be made to autocrop just those layers that are linked that would be a plus. :)

Thanks

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


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

Joined: Oct 25, 2010
Posts: 4757
Rod wrote:
Can a script be written, or is there one available to autocrop all layers in an xcf file?
So many times it seems i create small selections that need to be rotated and a script to autocrop all those at once would be so time saving.
If it could be made to autocrop just those layers that are linked that would be a plus. :)

Thanks


http://sourceforge.net/projects/gimp-to ... s/scripts/

wink, wink, nudge, nudge, say no more!

_________________
Image


Top
 Post subject: Re: Autocrop all layers
PostPosted: Mon Jun 06, 2011 4:23 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: Oct 29, 2010
Posts: 711
Location: Netherlands
Thanks ofnuts.
2 scripts in one go!
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: Mon Jun 06, 2011 4:41 pm  (#4) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
Doesn't work for me.

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


Top
 Post subject: Re: Autocrop all layers
PostPosted: Mon Jun 06, 2011 4:55 pm  (#5) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
Oregonian wrote:
Doesn't work for me.


Rod's id is hardcoded in it :)

Seriously, what do you mean by "doesn't work"? Do you "link" the layers before using the script?

_________________
Image


Top
 Post subject: Re: Autocrop all layers
PostPosted: Mon Jun 06, 2011 5:57 pm  (#6) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
When I use this, I linked 3 layers in the middle of 5, and set my selection of the areas I wanted to crop for the 3 linked, and it created a white box towards the bottom right of the bottom-most linked layer.

I tried using crop for selecting, etc. Same result.

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


Last edited by mahvin on Mon Jun 06, 2011 7:01 pm, edited 1 time in total.

Top
 Post subject: Re: Autocrop all layers
PostPosted: Mon Jun 06, 2011 6:34 pm  (#7) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
mahvin wrote:
When I use this, I linked 3 layers in the middle of 5, and set my selection of the areas I wanted to crop for the 3 linked, and it created a white box towards the bottom right of the bottom-most linked layer.

I tried using crop for selecting, etc. Same result.
"Autocropping" a layer means reducing it to the smallest rectangle that contains all the pixels that aren't completely transparent (see Layer/Autocrop Layer). The selection or the crop tool have nothing to do with that. The script does nothing more that running Autocrop Layer on all designated layers...

_________________
Image


Top
 Post subject: Re: Autocrop all layers
PostPosted: Mon Jun 06, 2011 7:00 pm  (#8) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
I'm not really understanding the usefulness of this technique. So, obviously, the scripts effect is lost on me.

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


Top
 Post subject: Re: Autocrop all layers
PostPosted: Mon Jun 06, 2011 7:10 pm  (#9) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
ofnuts you rock beyond all rockness! :)
i really love you man. :)

Thanks sooo much.It works excellent!

Mahvin i wanted the layer boundary closer to the image content without having to do it umpteen bazillion times for each layer.For me this is a priceless script. :)

Thanks again ofnuts.

_________________
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: Mon Jun 06, 2011 7:15 pm  (#10) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
Can you show me an example xcf of what you're talking about? The GIMP.org manual explains the single layer technique, which makes sense to me, but I'm not yet grasping how running this on x number of layers at the same time works. It only makes sense to me if every single layers' object is dead on centered. Otherwise each individual layer will still need to be manipulated to fit with each other layer object.

Look at these two files: one is done using the standard Layers/Autocrop on each individual layer. The other is done using ofnut's script. Totally different results, certainly not the outcome I was expecting, even though my initial understanding of "cropping" was misunderstood.


Attachments:
ofnuts_ac.xcf [27.9 KiB]
Downloaded 131 times
individual_ac.xcf [23.4 KiB]
Downloaded 110 times

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes
Top
 Post subject: Re: Autocrop all layers
PostPosted: Mon Jun 06, 2011 7:38 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
It isn't a script to modify many layers at once.it just shrinks the layer boundary around the contents of many linked layers at one time.
I do a lot of Layer to Image size on my projects and then need them all auto cropped back to their original boundary.
This makes it much faster.

For some reason i just like boundaries as close as possible when i rotate text or objects.Just me i guess but it seems more precise.

_________________
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: Mon Jun 06, 2011 7:48 pm  (#12) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
Now that made perfect sense. And it worked perfectly in that capacity. Sorry if anyone felt put on the spot, I just wanted to understand this, so I had to ask.

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


Top
 Post subject: Re: Autocrop all layers
PostPosted: Mon Jun 06, 2011 8:02 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
I understand mahvin, i would want to know what exactly a script can do for me before i download and install it too.I do not blame you for asking. :)

_________________
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: Mon Jun 06, 2011 8:13 pm  (#14) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Ofnuts, you may wish to re-examine your script to ensure that it is doing what you think it is doing. The Autocrop Layer plug-in has a couple of quirks which prescribe caution.

Firstly, 'plug-in-autocrop-layer' resizes the active layer based upon the contents of the layer that has been passed as a parameter. This typically means that you will want to execute 'gimp-image-set-active-layer' before running the plug-in (assuming you wish each layer to be autocropped individually based upon its own contents). This seemingly anomalous behavior is presumably intentional, considering how 'plug-in-autocrop' behaves (cropping the image based on the single parameter layer as opposed to cropping to the entire content of the image).

Slightly more problematic (in some situations) is that 'plug-in-autocrop-layer' does not seem to recognize when there is a difference in the layer offsets of the parameter layer and the active layer (for cases where these two layers are not the same). This behavior is rarely a concern for plug-in authors -- most often autocropping is performed on a layer based upon its own contents -- but one should be aware of the problem.

I do not have access to my notes on this at the moment, but a little experimentation should demonstrate the precise behavior of the plug-in (and explain the disparity in Mahvin's results).

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Autocrop all layers
PostPosted: Mon Jun 06, 2011 9:12 pm  (#15) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
That is odd i tried doing three layers and one object vanished all together. :lol
I made a white bg
created 3 transparent layers
created three distinct shapes on each layer.
Square on top - circle in the center - odd shape at the bottom
ran the script with all 3 layers linked and the bottom shape vanished into thin air but the boundary box was still there....And i can rotate it. :p

_________________
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: Mon Jun 06, 2011 9:15 pm  (#16) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
Image example to make it more clear -

Image

_________________
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: Mon Jun 06, 2011 11:30 pm  (#17) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
ofnuts wrote:
Seriously, what do you mean by "doesn't work"? Do you "link" the layers before using the script?
I had the same thing happen that mahvin did.

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


Top
 Post subject: Re: Autocrop all layers
PostPosted: Mon Jun 06, 2011 11:42 pm  (#18) 
Offline
GimpChat Member

Joined: Mar 29, 2011
Posts: 346
Location: Wisconsin
Here is a script that should do what you want -- at least it has worked for me with multiple layers that didn't necessarily overlap.

http://theuncle2k.deviantart.com/art/Au ... -149128828

The only problem is that it does all the layers in the image.
(Yes, the script does make each layer active and then autocrops it.)

_________________
Image


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

Joined: Oct 25, 2010
Posts: 4757
saulgoode wrote:
Ofnuts, you may wish to re-examine your script to ensure that it is doing what you think it is doing. The Autocrop Layer plug-in has a couple of quirks which prescribe caution.


OK, fixed in version 0.1 (on Sourceforge)

_________________
Image


Top
 Post subject: Re: Autocrop all layers
PostPosted: Tue Jun 07, 2011 10:05 am  (#20) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
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?

_________________
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 new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

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