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