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

Method get_or_add_image_part

src/docx/package.py:25–31  ·  view source on GitHub ↗

Return |ImagePart| containing image specified by `image_descriptor`. The image-part is newly created if a matching one is not already present in the collection.

(self, image_descriptor: str | IO[bytes])

Source from the content-addressed store, hash-verified

23 self._gather_image_parts()
24
25 def get_or_add_image_part(self, image_descriptor: str | IO[bytes]) -> ImagePart:
26 """Return |ImagePart| containing image specified by `image_descriptor`.
27
28 The image-part is newly created if a matching one is not already present in the
29 collection.
30 """
31 return self.image_parts.get_or_add_image_part(image_descriptor)
32
33 @lazyproperty
34 def image_parts(self) -> ImageParts:

Calls

no outgoing calls