def __init__(self, parent, index, offset=None, keyframe=None,
                 offsets=None, bytecounts=None):
        """Initialize TiffFrame from file or values.

        The file handle position must be at the offset to a valid IFD.

        """
        self._keyframe = None
        self.parent = parent
        self.index = index
        self.offset = offset

        if offsets is not None:
            # initialize "virtual frame" from offsets and bytecounts
            self._offsetscounts = offsets, bytecounts
            self._keyframe = keyframe
            return

        if offset is None:
            self.offset = parent.filehandle.tell()
        else:
            parent.filehandle.seek(offset)

        if keyframe is None:
            tags = {273, 279, 324, 325}
        elif keyframe.is_contiguous:
            tags = {256, 273, 324}
        else:
            tags = {256, 273, 279, 324, 325}

        dataoffsets = databytecounts = []

        for code, tag in self._gettags(tags):
            if code == 273 or code == 324:
                dataoffsets = list(tag.value)
            elif code == 279 or code == 325:
                databytecounts = list(tag.value)
            elif code == 256 and keyframe.imagewidth != tag.value:
                raise RuntimeError('incompatible keyframe')
            # elif code == 270:
            #     tagname = tag.name
            #     if tagname not in tags:
            #         tags[tagname] = bytes2str(tag.value)
            #     elif 'ImageDescription1' not in tags:
            #         tags['ImageDescription1'] = bytes2str(tag.value)
            # else:
            #     tags[tag.name] = tag.value

        if not dataoffsets:
            log.warning('TiffFrame %i is missing required tags', index)

        self._offsetscounts = dataoffsets, databytecounts

        if keyframe is not None:
            self.keyframe = keyframe
def __init__ ( self , parent , index , offset = None , keyframe = None , offsets = None , bytecounts = None ) : self . _keyframe = None self . parent = parent self . index = index self . offset = offset if offsets is not None : self . _offsetscounts = offsets , bytecounts self . _keyframe = keyframe return if offset is None : self . offset = parent . filehandle . tell ( ) else : parent . filehandle . seek ( offset ) if keyframe is None : tags = { 273 , 279 , 324 , 325 } elif keyframe . is_contiguous : tags = { 256 , 273 , 324 } else : tags = { 256 , 273 , 279 , 324 , 325 } dataoffsets = databytecounts = [ ] for code , tag in self . _gettags ( tags ) : if code == 273 or code == 324 : dataoffsets = list ( tag . value ) elif code == 279 or code == 325 : databytecounts = list ( tag . value ) elif code == 256 and keyframe . imagewidth != tag . value : raise RuntimeError ( 'incompatible keyframe' ) if not dataoffsets : log . warning ( 'TiffFrame %i is missing required tags' , index ) self . _offsetscounts = dataoffsets , databytecounts if keyframe is not None : self . keyframe = keyframe
Initialize TiffFrame from file or values.

        The file handle position must be at the offset to a valid IFD.