def parse(cls, fptr, offset, length):
        """Parse JPEG 2000 image header box.

        Parameters
        ----------
        fptr : file
            Open file object.
        offset : int
            Start position of box in bytes.
        length : int
            Length of the box in bytes.

        Returns
        -------
        ImageHeaderBox
            Instance of the current image header box.
        """
        # Read the box information
        read_buffer = fptr.read(14)
        params = struct.unpack('>IIHBBBB', read_buffer)
        height = params[0]
        width = params[1]
        num_components = params[2]
        bits_per_component = (params[3] & 0x7f) + 1
        signed = (params[3] & 0x80) > 1
        compression = params[4]
        colorspace_unknown = True if params[5] else False
        ip_provided = True if params[6] else False

        return cls(height, width, num_components=num_components,
                   bits_per_component=bits_per_component,
                   signed=signed,
                   compression=compression,
                   colorspace_unknown=colorspace_unknown,
                   ip_provided=ip_provided,
                   length=length, offset=offset)
def parse ( cls , fptr , offset , length ) : read_buffer = fptr . read ( 14 ) params = struct . unpack ( '>IIHBBBB' , read_buffer ) height = params [ 0 ] width = params [ 1 ] num_components = params [ 2 ] bits_per_component = ( params [ 3 ] & 0x7f ) + 1 signed = ( params [ 3 ] & 0x80 ) > 1 compression = params [ 4 ] colorspace_unknown = True if params [ 5 ] else False ip_provided = True if params [ 6 ] else False return cls ( height , width , num_components = num_components , bits_per_component = bits_per_component , signed = signed , compression = compression , colorspace_unknown = colorspace_unknown , ip_provided = ip_provided , length = length , offset = offset )
Parse JPEG 2000 image header box.

        Parameters
        ----------
        fptr : file
            Open file object.
        offset : int
            Start position of box in bytes.
        length : int
            Length of the box in bytes.

        Returns
        -------
        ImageHeaderBox
            Instance of the current image header box.