def write_png_depth(filename, depth):
 data = struct.pack('!i', depth)
 f = open(filename, 'r+b')
 try:
  f.seek((- LEN_IEND), 2)
  f.write(((DEPTH_CHUNK_LEN + DEPTH_CHUNK_START) + data))
  crc = (binascii.crc32((DEPTH_CHUNK_START + data)) & 4294967295)
  f.write(struct.pack('!I', crc))
  f.write(IEND_CHUNK)
 finally:
  f.close()

def write_png_depth ( filename , depth ) : data = struct . pack ( '!i' , depth ) f = open ( filename , 'r+b' ) try : f . seek ( ( - LEN_IEND ) , 2 ) f . write ( ( ( DEPTH_CHUNK_LEN + DEPTH_CHUNK_START ) + data ) ) crc = ( binascii . crc32 ( ( DEPTH_CHUNK_START + data ) ) & 4294967295 ) f . write ( struct . pack ( '!I' , crc ) ) f . write ( IEND_CHUNK ) finally : f . close ( )
write the special text chunk indicating the depth to a png file .