Return |InlineShape| containing image identified by `image_path_or_stream`. The picture is added to the end of this run. `image_path_or_stream` can be a path (a string) or a file-like object containing a binary image. If neither width nor height is specified, the p
(
self,
image_path_or_stream: str | IO[bytes],
width: int | Length | None = None,
height: int | Length | None = None,
)
| 57 | br.clear = clear |
| 58 | |
| 59 | def add_picture( |
| 60 | self, |
| 61 | image_path_or_stream: str | IO[bytes], |
| 62 | width: int | Length | None = None, |
| 63 | height: int | Length | None = None, |
| 64 | ) -> InlineShape: |
| 65 | """Return |InlineShape| containing image identified by `image_path_or_stream`. |
| 66 | |
| 67 | The picture is added to the end of this run. |
| 68 | |
| 69 | `image_path_or_stream` can be a path (a string) or a file-like object containing |
| 70 | a binary image. |
| 71 | |
| 72 | If neither width nor height is specified, the picture appears at |
| 73 | its native size. If only one is specified, it is used to compute a scaling |
| 74 | factor that is then applied to the unspecified dimension, preserving the aspect |
| 75 | ratio of the image. The native size of the picture is calculated using the dots- |
| 76 | per-inch (dpi) value specified in the image file, defaulting to 72 dpi if no |
| 77 | value is specified, as is often the case. |
| 78 | """ |
| 79 | inline = self.part.new_pic_inline(image_path_or_stream, width, height) |
| 80 | self._r.add_drawing(inline) |
| 81 | return InlineShape(inline) |
| 82 | |
| 83 | def add_tab(self) -> None: |
| 84 | """Add a ``<w:tab/>`` element at the end of the run, which Word interprets as a |