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

Method image

src/docx/drawing/__init__.py:47–59  ·  view source on GitHub ↗

An `Image` proxy object for the image in this (picture) drawing. Raises `ValueError` when this drawing does contains something other than a picture. Use `.has_picture` to qualify drawing objects before using this property.

(self)

Source from the content-addressed store, hash-verified

45
46 @property
47 def image(self) -> Image:
48 """An `Image` proxy object for the image in this (picture) drawing.
49
50 Raises `ValueError` when this drawing does contains something other than a picture. Use
51 `.has_picture` to qualify drawing objects before using this property.
52 """
53 picture_rIds = self._drawing.xpath(".//pic:blipFill/a:blip/@r:embed")
54 if not picture_rIds:
55 raise ValueError("drawing does not contain a picture")
56 rId = picture_rIds[0]
57 doc_part = self.part
58 image_part = doc_part.related_parts[rId]
59 return image_part.image

Callers

nothing calls this directly

Calls 1

xpathMethod · 0.80

Tested by

no test coverage detected