def extract_jpeg_thumbnail(self):
        """
        Extract JPEG thumbnail.

        (Thankfully the JPEG data is stored as a unit.)
        """
        thumb_offset = self.tags.get('Thumbnail JPEGInterchangeFormat')
        if thumb_offset:
            self.file.seek(self.offset + thumb_offset.values[0])
            size = self.tags['Thumbnail JPEGInterchangeFormatLength'].values[0]
            self.tags['JPEGThumbnail'] = self.file.read(size)

        # Sometimes in a TIFF file, a JPEG thumbnail is hidden in the MakerNote
        # since it's not allowed in a uncompressed TIFF IFD
        if 'JPEGThumbnail' not in self.tags:
            thumb_offset = self.tags.get('MakerNote JPEGThumbnail')
            if thumb_offset:
                self.file.seek(self.offset + thumb_offset.values[0])
                self.tags['JPEGThumbnail'] = self.file.read(thumb_offset.field_length)
def extract_jpeg_thumbnail ( self ) : thumb_offset = self . tags . get ( 'Thumbnail JPEGInterchangeFormat' ) if thumb_offset : self . file . seek ( self . offset + thumb_offset . values [ 0 ] ) size = self . tags [ 'Thumbnail JPEGInterchangeFormatLength' ] . values [ 0 ] self . tags [ 'JPEGThumbnail' ] = self . file . read ( size ) if 'JPEGThumbnail' not in self . tags : thumb_offset = self . tags . get ( 'MakerNote JPEGThumbnail' ) if thumb_offset : self . file . seek ( self . offset + thumb_offset . values [ 0 ] ) self . tags [ 'JPEGThumbnail' ] = self . file . read ( thumb_offset . field_length )
Extract JPEG thumbnail.

        (Thankfully the JPEG data is stored as a unit.)