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,
)
| 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 | |
| 168 | def _ImageHeaderFactory(stream: IO[bytes]): |