Call for Submission
NAB 2012 Best of the Best Show Reel
Submit your work today!
  • 1/3
You are here: Forum Home / Autodesk® Maya® / Python / how to read iff files?
  RSS 2.0 ATOM  

how to read iff files?
Rate this thread
 
33339
 
Permlink of this thread   Subscribe to this thread
avatar
  • Total Posts: 3
  • Joined: 22 August 2006 02:33 AM

hello,

i would like be abble to read a 32bits iff file with a python script to get the z range on the sequence i’ve rendered.

I tried to read it with the command open(file.iff,"rb") but i don’t know the iff’structure.
I tried also to use the maya python api image or else but i don’t know how to implement an api…

Is there someone that have done this and could help me?

Thanks

Nicolas Pastrana



Replies: 0
avatar
  • _stev_
  • Posted: 17 December 2009 07:24 AM

I know this is kind of old, but may still be of some use:

import maya.OpenMaya as OpenMaya
import os
.path

lFileName 
r'd:\zdepthtest.iff'

def getDepthMapRange(pImageName):
   
# The image
   
lImage OpenMaya.MImage()
   lImage
.readFromFile(pImageName)
   
   
if not lImage.haveDepth():
      print 
'No Z-Depth map channel found'
      
return

   
# Calculate the size of the dmap
   
widthPtr OpenMaya.MScriptUtil().asUintPtr()
   heightPtr 
OpenMaya.MScriptUtil().asUintPtr()
   lImage
.getDepthMapSize(widthPtrheightPtr)
   
# Get the width and height of the image in pixels
   
width OpenMaya.MScriptUtil().getUint(widthPtr)
   height 
OpenMaya.MScriptUtil().getUint(heightPtr)
   numPixels 
(width*height)
   
# Pixels object, we use this to read the values
   
lPixels lImage.depthMap()

   lHighValue 
= -1.0
   lLowValue 
0.0
   
# Use this script util to read the values
   
lPixelUtil OpenMaya.MScriptUtil()

   
for i in range(numPixels):
      
depthValue lPixelUtil.getFloatArrayItem(lPixelsi)

      
if depthValue lLowValue:
         
lLowValue depthValue
      
# Ignore zero values
      
if cmp(0.0depthValue) and depthValue lHighValue:
         
lHighValue depthValue

   print(
'Z Range: %f to %f' (lLowValuelHighValue))

if os.path.isfile(lFileName):
   
getDepthMapRange(lFileName)

Stev



Replies: 0




   
  Settings Choose Theme color: