glymur/jp2box.py
def parse(cls, fptr, offset, length):
        """Parse JPEG 2000 color specification box.

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

        Returns
        -------
        ColourSpecificationBox
            Instance of the current colour specification box.
        """
        num_bytes = offset + length - fptr.tell()
        read_buffer = fptr.read(num_bytes)

        lst = struct.unpack_from('>BBB', read_buffer, offset=0)
        method, precedence, approximation = lst

        if method == 1:
            # enumerated colour space
            colorspace, = struct.unpack_from('>I', read_buffer, offset=3)
            icc_profile = None

        else:
            # ICC profile
            colorspace = None
            if (num_bytes - 3) < 128:
                msg = (
                    f"An ICC profile header in a ColourSpecificationBox at "
                    f"byte offset {offset} is corrupt, the length is only "
                    f"{num_bytes - 3} when it should be at least 128."
                )
                warnings.warn(msg, UserWarning)
                icc_profile = None
            else:
                icc_profile = read_buffer[3:]

        return cls(method=method,
                   precedence=precedence,
                   approximation=approximation,
                   colorspace=colorspace,
                   icc_profile=icc_profile,
                   length=length,
                   offset=offset)
Parse JPEG 2000 color specification box.

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

        Returns
        -------
        ColourSpecificationBox
            Instance of the current colour specification box.
        
Parse JPEG 2000 color specification box.
Parameters

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

Returns

ColourSpecificationBox
Instance of the current colour specification box.
Parse JPEG 2000 color specification box . Parameters fptr : file Open file object . offset : int Start position of box in bytes . length : int Length of the box in bytes . Returns ColourSpecificationBox Instance of the current colour specification box .
def parse(cls, fptr, offset, length):
        num_bytes = offset + length - fptr.tell()
        read_buffer = fptr.read(num_bytes)
        lst = struct.unpack_from('>BBB', read_buffer, offset=0)
        method, precedence, approximation = lst
        if method == 1:
            colorspace, = struct.unpack_from('>I', read_buffer, offset=3)
            icc_profile = None
        else:
            colorspace = None
            if (num_bytes - 3) < 128:
                msg = (
                    f"An ICC profile header in a ColourSpecificationBox at "
                    f"byte offset {offset} is corrupt, the length is only "
                    f"{num_bytes - 3} when it should be at least 128."
                )
                warnings.warn(msg, UserWarning)
                icc_profile = None
            else:
                icc_profile = read_buffer[3:]
        return cls(method=method,
                   precedence=precedence,
                   approximation=approximation,
                   colorspace=colorspace,
                   icc_profile=icc_profile,
                   length=length,
                   offset=offset)
def parse ( cls , fptr , offset , length ) : num_bytes = offset + length - fptr . tell ( ) read_buffer = fptr . read ( num_bytes ) lst = struct . unpack_from ( '>BBB' , read_buffer , offset = 0 ) method , precedence , approximation = lst if method == 1 : colorspace , = struct . unpack_from ( '>I' , read_buffer , offset = 3 ) icc_profile = None else : colorspace = None if ( num_bytes - 3 ) < 128 : msg = ( f"An ICC profile header in a ColourSpecificationBox at " f"byte offset {offset} is corrupt, the length is only " f"{num_bytes - 3} when it should be at least 128." ) warnings . warn ( msg , UserWarning ) icc_profile = None else : icc_profile = read_buffer [ 3 : ] return cls ( method = method , precedence = precedence , approximation = approximation , colorspace = colorspace , icc_profile = icc_profile , length = length , offset = offset )
Parse JPEG 2000 color specification box.
Parse JPEG 2000 color specification box .
"""Parse JPEG 2000 color specification box.

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

        Returns
        -------
        ColourSpecificationBox
            Instance of the current colour specification box.
        """ # enumerated colour space # ICC profile
cls
fptr
offset
length