cutcutcodec.core.io.read_image.ContainerInputImage

class cutcutcodec.core.io.read_image.ContainerInputImage(filename: str | bytes | Path)[source]

Decode an image.

Attributes

filenamepathlib.Path

The path to the physical file that contains the extracted image stream (readonly).

Examples

>>> from cutcutcodec.core.io.read_image import ContainerInputImage
>>> from cutcutcodec.utils import get_project_root
>>> (stream,) = ContainerInputImage(get_project_root() / "examples" / "logo.png").out_streams
>>> stream.snapshot(0, (9, 9))[..., 3]
tensor([[0.0000, 0.0415, 0.5152, 0.8748, 0.9872, 0.8744, 0.5164, 0.0422, 0.0000],
        [0.0418, 0.7853, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 0.7851, 0.0420],
        [0.5156, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 0.5141],
        [0.8749, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 0.8732],
        [0.9871, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 0.9861],
        [0.8745, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 0.8727],
        [0.5150, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 0.5137],
        [0.0417, 0.7838, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 0.7842, 0.0413],
        [0.0000, 0.0411, 0.5139, 0.8732, 0.9865, 0.8729, 0.5144, 0.0417, 0.0000]])
>>>

Initialise and create the class.

Parameters

filenamepathlike

Path to the file to be decoded.

Raises

cutcutcodec.core.exceptions.DecodeError

If it fail to extract any multimedia stream from the provided file.

property filename: Path

Return the path to the physical file that contains the extracted image stream.