autoCrop v1.1
This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: Kire Timov
Auto Crop script to utilize the curve's tool auto crop feature to its fullest on multiple inputs, with full control over channels and layers, frame range, scan in overscan, and additional safety pixels.
Requirements:
11.0, 10.5, 10.0, 9.0, 8.0 or later
Linux, Mac, Windows
11.0, 10.5, 10.0, 9.0, 8.0 or later
Linux, Mac, Windows
10 Jun 2018
373
I wrote the 'Auto Crop' script to offer the best possible experience when you need to utlizie the curve tool 'auto crop' feature, despite that other solutions have already been offered on nukepedia.
Features:
- range - (input/global/custom), Let's you choose the frame range for the Auto Crop
- channels - Select the channel you want to scan and then tick the layers you want the Auto Crop to use for that channel (red/green/blue/alpha)
- overscan - If overscan is ticked, the Auto Crop will scan for pixels outside of the image format if avialable
- add 30 safety pixels - Adds 30 pixles (15px in one direction and 15 on the other) to avoid problems later in comp that can arise in certain situations for images that were cropped on the nearest pixel.
- reconnection - (not listed) After the Auto Crop script is done processing, it will automatically place an animated crop (delete the curve tool) and reconnect any nodes, before or after depending on the selection that you started the script on. (including masks or complex branches bellow)
How to use:
- Select one or more nodes that you want to Auto Crop.
- Run the script
- Choose the range that you want to to scan for the Auto Crop
- Choose the channlel and the layers that you want the Auto Crop to scan in (by default only the alpha layer is selected in rgba, that is if you have an alpha channel, becase usually it's the most efficient layer to scan.)
- Leave the 'overscan' ticked if you want to let the auto crop scan for additional pixles outside the image format if avialable.
- I recommend you leave the 'add additional 30 safety pixles' ticked, to avoid problems later in your comp. Another use of this feature is when you don't have an alpha channel in a CG render and you need to scan the rgb for example, you can safely choose to scan only one layer for efficiency (red or green or blue) and be sure that everything have been scanned properly, even if some of the layers in the last pixles are shorter and are missing data, adding those 30 safety pixles will make sure that you will have everything scanned for every layer, in almost 99.999% of the times. (the 30 safety pixels are added after the prcoession via expression, so they do not hinder performance while scanning)
- Click OK and wait for the process to finish.
How to install:
- Copy the file 'autoCrop.py' to your .nuke directory. (e.g. C:\Users\frank\.nuke)
- Add the following lines in your 'menu.py' (located in your .nuke directory):
import autoCrop
scripts_m = nuke.menu('Nuke').addMenu('Scripts')
scripts_m.addCommand('Auto Crop', 'autoCrop.autoCrop()') - Start Nuke and you can find the script in a menu called 'Scripts' (located in the top in menu in Nuke)
Upcomming features:
- Scan in background - when i find a solution how to execute the curve tool in the background without interfering with your work.
UPDATES:
10 June 2018: Version 1.1
Changes:
- 'Add 10 safety pixels' now changed to 'Add 30 safety pixles' (15 on the left and 15 on the right). The reason is that the 10 safety pixles were oftenly not enough, especially when you add post motionblur.
Bug fixes:
- If you entered a single frame, when using the 'custom' frame range option the script would fail - fixed
- The 'Add additional 10 pixles' chekbox was always happening, even if it was not ticked - fixed
# @Author: Kire Timov
# @Date: Saturday, May 26th 2018, 6:45:53 am
# @Email: [email protected]
# @Project: Auto Crop v1.0
# @Last modified by: Kire Timov
# @Last modified time: Sunday, May 27th 2018, 10:44:33 am
# @Copyright: # @ Copyright (c) 2017, Kire Timov
# @ All rights reserved.
# @
# @ Redistribution and use in source and binary forms, with or without
# @ modification, are permitted provided that the following conditions are met:
# @ * Redistributions of source code must retain the above copyright
# @ notice, this list of conditions and the following disclaimer.
# @ * Redistributions in binary form must reproduce the above copyright
# @ notice, this list of conditions and the following disclaimer in the
# @ documentation and/or other materials provided with the distribution.
# @ * Redistribution of this software in source or binary forms shall be free
# @ of all charges or fees to the recipient of this software.
# @
# @ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER 'AS IS' AND
# @ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# @ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# @ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# @ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# @ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# @ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# @ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# @ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# @ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Please login in order to download these files.
Comments
### menu.py ###########
import nuke
m=nuke.menu('Nuke')
n=m.addMenu('python')
# shrink and grow CropNodeBox
import growCropNodeBox
n.addCommand('crop/growCropNodeBox', 'growCropNodeBo x.growCropNodeB ox()', 'alt+=')
n.addCommand('crop/shrinkCropNodeBox', 'growCropNodeBo x.shrinkCropNod eBox()', 'alt+-')
#### growCropNodeBox .py ####
import nuke
def growCropNodeBox ():
node = nuke.selectedNo de()
box = node.knob('box' )
if box.isAnimated( ) == True:
nodeName = node.knob('name ').value()
nuke.animation( (nodeName)+'.bo x.x', 'move', ['y', 'y-1'])
nuke.animation( (nodeName)+'.bo x.y', 'move', ['y', 'y-1'])
nuke.animation( (nodeName)+'.bo x.r', 'move', ['y', 'y+1'])
nuke.animation( (nodeName)+'.bo x.t', 'move', ['y', 'y+1'])
else:
newBox = []
for n in box.getValue()[ 0:2]:
n = n - 1
newBox.append(n )
for n in box.getValue() [2:5]:
n = n + 1
newBox.append(n )
box.setValue(newBox)
def shrinkCropNodeB ox():
node = nuke.selectedNo de()
box = node.knob('box' )
if box.isAnimated( ) == True:
nodeName = node.knob('name ').value()
nuke.animation( (nodeName)+'.bo x.x', 'move', ['y', 'y+1'])
nuke.animation( (nodeName)+'.bo x.y', 'move', ['y', 'y+1'])
nuke.animation( (nodeName)+'.bo x.r', 'move', ['y', 'y-1'])
nuke.animation( (nodeName)+'.bo x.t', 'move', ['y', 'y-1'])
else:
newBox = []
for n in box.getValue() [0:2]:
n = n + 1
newBox.append(n )
for n in box.getValue() [2:5]:
n = n - 1
newBox.append(n )
nuke.selectedNo de().knob('box').setValue(newBox)
RSS feed for comments to this post