def read_png_depth(filename):
 result = None
 f = open(filename, 'rb')
 try:
  f.seek((- (LEN_IEND + LEN_DEPTH)), 2)
  depthchunk = f.read(LEN_DEPTH)
  if (not depthchunk.startswith((DEPTH_CHUNK_LEN + DEPTH_CHUNK_START))):
   return None
  result = struct.unpack('!i', depthchunk[14:18])[0]
 finally:
  f.close()
 return result

def read_png_depth ( filename ) : result = None f = open ( filename , 'rb' ) try : f . seek ( ( - ( LEN_IEND + LEN_DEPTH ) ) , 2 ) depthchunk = f . read ( LEN_DEPTH ) if ( not depthchunk . startswith ( ( DEPTH_CHUNK_LEN + DEPTH_CHUNK_START ) ) ) : return None result = struct . unpack ( '!i' , depthchunk [ 14 : 18 ] ) [ 0 ] finally : f . close ( ) return result
read the special text chunk indicating the depth from a png file .