MCPcopy Index your code
hub / github.com/python-openxml/python-docx / _from_stream

Method _from_stream

src/docx/image/image.py:154–165  ·  view source on GitHub ↗

Return an instance of the |Image| subclass corresponding to the format of the image in `stream`.

(
        cls,
        stream: IO[bytes],
        blob: bytes,
        filename: str | None = None,
    )

Source from the content-addressed store, hash-verified

152
153 @classmethod
154 def _from_stream(
155 cls,
156 stream: IO[bytes],
157 blob: bytes,
158 filename: str | None = None,
159 ) -> Image:
160 """Return an instance of the |Image| subclass corresponding to the format of the
161 image in `stream`."""
162 image_header = _ImageHeaderFactory(stream)
163 if filename is None:
164 filename = "image.%s" % image_header.default_ext
165 return cls(blob, filename, image_header)
166
167
168def _ImageHeaderFactory(stream: IO[bytes]):

Callers 3

from_blobMethod · 0.80
from_fileMethod · 0.80

Calls 1

_ImageHeaderFactoryFunction · 0.85

Tested by 1