Sunday, January 20, 2013

saveImage

saveImage.py

Hi nuker's finally found a solution for our long time wish and expectation. Now you can save image from the viewer. Like eyeon fusion and other application.

saveImage.py will allowing you to choose the path and file name and type. Now you can choose the image as any format (which ever nuke support). example jpg, tga, tiff, png et.

Added extra future channels. user can select channels to save image.

Added extra future while saving as exr you can choose the Data type. Default its in 16bit-half, either you can choose32-bit float. Fixed sub-sampling to 4:4:4 while save as .jpg.

Go to active viewer and right click select the save image as. It will pop-up a window like below image.




Choose your path and file type.


Hit ok it will save your active viewer result as image, It creates a read node and import your saved image into nuke.





If you forget to choose path and file type nuke will pop-up a message box like below image:


Hope this will help you Nuker's.

copy paste the following line to your menu.py.

nuke.menu( 'Viewer' ).addCommand( 'save image as', "saveImage.saveImage()")

Download from: nukepedia
Download from: skydrive


Add this script into your custom .nuke DIR as saveImage.py:

'''
Created on 19-jan-2013
Updated on 2 april 2016
@author: satheesh-R
mail - satheesrev@gmail.com
'''

import nuke, nukescripts
def saveImage ():

    ### Getting Lut list from root
    LutList = [n.split(" ")[0] for n in nuke.root()['luts'].toScript().split("\n")]
    Luts = '\n'.join(LutList)

    ### creating panel and assign buttons
    ef = nuke.Panel("saveImage As......  by satheesh-r", 420)
    ef.addFilenameSearch("Save Image As:\nchoose path & file type", "")
    ef.addButton("cancel")
    ef.addEnumerationPulldown('channels', "rgb rgba all")
    ef.addEnumerationPulldown('Color Space', Luts)
    ef.addEnumerationPulldown('Exr data type', "16bit-half 32bit-float")
    ef.addButton("ok")
    window=ef.show()

    ### getting values from panel
    exrtype = ef.value('Exr data type')
    channel = ef.value('channels')
    path = ef.value("Save Image As:\nchoose path & file type")
    colorSpace = ef.value('Color Space')
    fileType = path.split('.')[-1]

    ### User cancel the oparation
    if window == 0 :
        return

    ### if file format not found
    fileFormat = path.split('/')[-1]
    findDot = ('.')
    for dot in findDot:
        if dot in fileFormat:
            if dot == '.':
           
                ### getting path from user input
                if path == "":
                    nuke.message('no file path selected ')
                if path == "":
                    return
           
                ### getting active node
                curViewer = nuke.activeViewer()
                curNode = curViewer.node()
                acticeVinput = curViewer.activeInput()
                curN = curNode.input(acticeVinput)
           
                ### creating temp write
                w = nuke.createNode("Write")
                w.setName("tempWrite")
                w.setInput(0, curN)
                w['file'].setValue(path)
                w['colorspace'].setValue(colorSpace)
                w['channels'].setValue(channel)
           
                ### if file type is jpg
                if fileType == 'jpg' :
                    w['_jpeg_sub_sampling'].setValue(2)
                    w['_jpeg_quality'].setValue(1)
           
                ### if file type is exr
                if fileType == 'exr' :
                    w['datatype'].setValue(exrtype)
                    w['compression'].setValue(2)
                    w['metadata'].setValue(0)
           
                ### setting current frame for render
                curFrame = nuke.frame()
                if curFrame =="":
                  curFrame = curFrame
           
                ### execute write node
                nuke.execute(nuke.selectedNode(), (int(curFrame)), curFrame)
                name = w.knob('file').value()
                nukescripts.node_delete(popupOnError=True)
           
                ### create Read node
                r = nuke.createNode("Read")
                r['file'].setValue(name)
                curFrame = nuke.frame()
                r['first'].setValue(int(curFrame))
                r['last'].setValue(int(curFrame))
        else:
            nuke.message('forget to choose file format')
            return

Wednesday, January 2, 2013

shuffleAlpha.py

shuffleAlpha

Usually we use shuffle node to extract matte's from ID pass. For to do this we add a shuffle node and select the channel which need to be alpha channel.
 
This script will simplify this work, Its pop-up a panel (window)  called "selectChannel to shuffle" and you should choose your channel and click ok. This script will automatically done the above job. shuffleAlpha script also label the node like (red-->Alpha).

 Added extra future called "to All channel". By default "to All channel" is unchecked, If you select your channel and hit ok it will give you below result.
(This script keep other channels black rather then "alpha" channel)


I used to work like this, Because off work-flow optimisation. For more information about nuke work-flow optimisation tips.... nuke-workflow-optimisation-tips


With "to All channel" checked result:



Also shuffleAlpha.py will label the shuffle node according to your selection and create a stickyNote node and insert the result on it.


Added rgba to alpha. Some time we need to merge all channels together to alpha. If you select 'rgba' this script will create a expression node, merge all the channel together and convert it to alpha. Output value are clamped.







Hope this will help you friends.

Download from: nukepedia

Download from: skydrive

(or)

Copy below code and enjoy.


import sys
import nuke

'''
Created on 2 Jan 2013

@author: satheesh.R
contact: satheesrev@gmail.com
'''
## creating panel
def  shuffleAlpha():
    sa = nuke.Panel("shuffleAlpha.......  by satheesh-r", 400)
    sa.addEnumerationPulldown('selectChannel to shuffle', 'red green blue alpha rgba')
    sa.addBooleanCheckBox("to All channels", False)
    sa.addButton("cancel")
    sa.addButton("ok")
    result = sa.show()
    channel=sa.value("selectChannel to shuffle")
    value=sa.value("to All channels")
    ## continue the function if user hit ok
    if result == 0 :
        return

    if channel == 'rgba' :
        ex = nuke.createNode('Expression', inpanel = False)
        ex['expr3'].setValue('clamp(r+g+b+a)')
        ex['label'].setValue(channel+ ' ---> alpha')
        ex['note_font_size'].setValue(15)
        xpos = ex.xpos()
        ypos = ex.ypos()
        sn = nuke.createNode('StickyNote', inpanel = False)
        sn['label'].setValue(channel+ ' channels converted to alpha\n value clamped')
        sn['xpos'].setValue(xpos+110)
        sn['ypos'].setValue(ypos)


    ## Create shuffle node and set selected channel to all channels
    elif value == True :
        sh = nuke.createNode("Shuffle", inpanel = False)
        sh['alpha'].setValue(channel)
        sh['red'].setValue(channel)
        sh['green'].setValue(channel)
        sh['blue'].setValue(channel)
        sh['label'].setValue(channel+'-->All')
        sh['note_font_size'].setValue(20)

        ## add stickyNotes with shuffle information
        xpos = sh.xpos()
        ypos = sh.ypos()
        sn = nuke.createNode('StickyNote', inpanel = False)
        sn['xpos'].setValue(xpos+110)
        sn['ypos'].setValue(ypos+10)
        sn['label'].setValue(channel+ ' channel replaced\n with all channels')

    ## Create shuffle node and set selected channel to alpha channel only, keep other channels black
    elif value == False :
        sh = nuke.createNode("Shuffle", inpanel = False)
        sh['alpha'].setValue(channel)
        sh['red'].setValue('black')
        sh['green'].setValue('black')
        sh['blue'].setValue('black')
        sh['label'].setValue(channel+'-->alpha')
        sh['note_font_size'].setValue(20)

        ## add stickyNotes with shuffle information
        xpos = sh.xpos()
        ypos = sh.ypos()
        sn = nuke.createNode('StickyNote', inpanel = False)
        sn['xpos'].setValue(xpos+110)
        sn['ypos'].setValue(ypos+10)
        sn['label'].setValue(channel+ ' channel converted to alpha\n other channels switched to black')

        ## setting node tile color based on user selection
        if channel == "red" :
            sh['tile_color'].setValue(4278190335)
        if channel == "green" :
            sh['tile_color'].setValue(16711935)
        if channel == "blue" :
            sh['tile_color'].setValue(65535)
        if channel == "alpha" :
            sh['tile_color'].setValue(4278124287)

    else:
        return

scale up and down cornerpin node

global scale up and down cornerpin This script help you to global scale up or down the selected cornerpin. Recently i had situation to ...