code: def parse_tag(self, dtype, count, offset_buf):
          
          try:
              fmt = self.datatype2fmt[dtype][0] * count
              payload_size = self.datatype2fmt[dtype][1] * count
          except KeyError:
              msg = 'Invalid TIFF tag datatype ({0}).'.format(dtype)
              raise IOError(msg)
  
          if payload_size <= 4:
              # Interpret the payload from the 4 bytes in the tag entry.
              target_buffer = offset_buf[:payload_size]
          else:
              # Interpret the payload at the offset specified by the 4 bytes in
              # the tag entry.
              offset, = struct.unpack(self.endian + 'I', offset_buf)
              target_buffer = self.read_buffer[offset:offset + payload_size]
  
          if dtype == 2:
              # ASCII
              payload = target_buffer.decode('utf-8').rstrip('\x00')
  
          else:
              payload = struct.unpack(self.endian + fmt, target_buffer)
              if dtype == 5 or dtype == 10:
                  # Rational or Signed Rational.  Construct the list of values.
                  rational_payload = []
                  for j in range(count):
                      value = float(payload[j * 2]) / float(payload[j * 2 + 1])
                      rational_payload.append(value)
                  payload = rational_payload
              if count == 1:
                  # If just a single value, then return a scalar instead of a
                  # tuple.
                  payload = payload[0]
  
          return payload
docs: Interpret an Exif image tag data payload.