The first step is to handle the view names. Eventually I’d like to do this automatically, but for now we’ll hard code them. We build a leftInFilePattern and a rightInFilePattern based on the inFilePattern:leftInFilePattern = inFilePattern.replace( '%v', 'left' )
rightInFilePattern = inFilePattern.replace( '%v', 'right' )
This replaces Nuke’s ‘%v’ with ‘left’ and ‘right’. Please change ‘left’ and ‘right’ to whatever naming convention your facility uses.
Your script has a few lines where you determine inFile based on inFilePattern. We’ll change this to determine leftInFile and rightInFile based on leftInFilePattern and rightInFilePattern. For example, change:
inFile = ReplaceFilenameHashesWithNumber(inFilePattern, frameNumber)
to:leftInFile = ReplaceFilenameHashesWithNumber(leftInFilePattern, frameNumber)
rightInFile = ReplaceFilenameHashesWithNumber(rightInFilePattern, frameNumber)
Similarly, anywhere you call Image.ReadFromFile() should be changed to read an image for both the left and right eyes. For example, change:
inFrame = Image.ReadFromFile(inFile)
to:leftInFrame = Image.ReadFromFile(leftInFile)
rightInFrame = Image.ReadFromFile(rightInFile)
Next we need some way to resize the image. I think we want a ‘fit’ resize while halving the aspect ratio. Here’s a function that will do that for us:[code]def ResizeWithPixelAspectScale( self, width, height, pixelAspectScale ):
if width <= 0:
raise RuntimeError(‘width must be a positive number’)
if height <= 0:
raise RuntimeError(‘height must be a positive number’)
if pixelAspectScale <= 0:
raise RuntimeError(‘pixelAspectScale must be a positive number’)
sourceAR = float(pixelAspectScale) * self.width / self.height
destAR = float(width) / height
if sourceAR == destAR:
self.Resize( width, height, 'distort' )
else:
image = copy.deepcopy( self )
self.Resize( width, height )
self.SetToColor( ColorRGBA( 0, 0, 0, 0 ) )
if sourceAR > destAR:
image.Resize( width, int(round(width/sourceAR)), 'distort' )
else:
image.Resize( int(round(height*sourceAR)), height, 'distort' )
self.CompositeWithGravity( image, PositionalGravity.CenterGravity, CompositeOperator.CopyCompositeOp )
Image.ResizeWithPixelAspectScale = ResizeWithPixelAspectScale[/code]We should probably add an option like this to Image.Resize().
Finally we resize the left and right image, and composite them onto the output frame:[code]leftInFrame.ResizeWithPixelAspectScale(proxyWidth/2, proxyHeight, 0.5)
rightInFrame.ResizeWithPixelAspectScale(proxyWidth/2, proxyHeight, 0.5)
bgFrame = Image.CreateImage(proxyWidth, proxyHeight)
bgFrame.CompositeWithPositionAndGravity(leftInFrame, 0.25, 0.5, PositionalGravity.CenterGravity, CompositeOperator.CopyCompositeOp)
bgFrame.CompositeWithPositionAndGravity(rightInFrame, 0.75, 0.5, PositionalGravity.CenterGravity, CompositeOperator.CopyCompositeOp)[/code]
Please find attached a copy of your script that includes these changes.
Please let me know if you have any questions, or if there’s anything we should change.
IS_1_HD_stereo.zip (2.77 KB)