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

Method new_pic_inline

src/docx/parts/story.py:60–74  ·  view source on GitHub ↗

Return a newly-created `w:inline` element. The element contains the image specified by `image_descriptor` and is scaled based on the values of `width` and `height`.

(
        self,
        image_descriptor: str | IO[bytes],
        width: int | Length | None = None,
        height: int | Length | None = None,
    )

Source from the content-addressed store, hash-verified

58 return self._document_part.get_style_id(style_or_name, style_type)
59
60 def new_pic_inline(
61 self,
62 image_descriptor: str | IO[bytes],
63 width: int | Length | None = None,
64 height: int | Length | None = None,
65 ) -> CT_Inline:
66 """Return a newly-created `w:inline` element.
67
68 The element contains the image specified by `image_descriptor` and is scaled
69 based on the values of `width` and `height`.
70 """
71 rId, image = self.get_or_add_image(image_descriptor)
72 cx, cy = image.scaled_dimensions(width, height)
73 shape_id, filename = self.next_id, image.filename
74 return CT_Inline.new_pic_inline(shape_id, rId, filename, cx, cy)
75
76 @property
77 def next_id(self) -> int:

Callers 1

Calls 2

get_or_add_imageMethod · 0.95
scaled_dimensionsMethod · 0.80

Tested by 1