Skip to content

Image

DrawImage class for “draw:image” tag, DrawFillImage for “draw:fill-image” tag, and DrawMarker for “draw:marker” tag.

Classes:

Name Description
DrawFillImage

A link to a bitmap resource, “draw:fill-image”.

DrawImage

An ODF image, “draw:image”.

DrawMarker

A marker, “draw:marker”, which is used to draw polygons at the start

DrawFillImage

Bases: Element

A link to a bitmap resource, “draw:fill-image”.

Methods:

Name Description
__init__

Initialize a DrawFillImage, “draw:fill-image”.

__str__

Attributes:

Name Type Description
actuate
display_name
family
height
name
show
url
width
xlink_type
Source code in odfdo/image.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
class DrawFillImage(Element):
    """A link to a bitmap resource, "draw:fill-image"."""

    _tag = "draw:fill-image"
    _properties: tuple[PropDef | PropDefBool, ...] = (
        PropDef("name", "draw:name"),
        PropDef("display_name", "draw:display-name"),
        PropDef("height", "svg:height"),
        PropDef("width", "svg:width"),
        PropDef("url", "xlink:href"),
        PropDef("xlink_type", "xlink:type"),
        PropDef("show", "xlink:show"),
        PropDef("actuate", "xlink:actuate"),
    )

    def __init__(
        self,
        name: str | None = None,
        display_name: str | None = None,
        height: str | None = None,
        width: str | None = None,
        url: str = "",
        xlink_type: str = "simple",
        show: str = "embed",
        actuate: str = "onLoad",
        **kwargs: Any,
    ) -> None:
        """Initialize a DrawFillImage, "draw:fill-image".

        The `draw:fill-image` element specifies a link to a bitmap resource.
        Fill images are not available as automatic styles and are typically
        used within the `office:styles` element.

        Args:
            name: The internal name of the fill image.
            display_name: The display name of the fill image.
            height: The height of the fill image (e.g., "10cm").
            width: The width of the fill image (e.g., "15cm").
            url: The URL or internal path of the image.
            xlink_type: The XLink type, usually "simple".
            show: How the image should be shown, usually "embed".
            actuate: When the image should be loaded, usually "onLoad".
            **kwargs: Additional keyword arguments for the parent `DrawImage` class.
        """
        super().__init__(**kwargs)
        if self._do_init:
            self.name = name
            self.display_name = display_name
            self.height = height
            self.width = width
            self.url = url
            self.xlink_type = xlink_type
            self.show = show
            self.actuate = actuate
        self.family = ""

    def __str__(self) -> str:
        return f"({self.url})"

_properties class-attribute instance-attribute

_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef("name", "draw:name"),
    PropDef("display_name", "draw:display-name"),
    PropDef("height", "svg:height"),
    PropDef("width", "svg:width"),
    PropDef("url", "xlink:href"),
    PropDef("xlink_type", "xlink:type"),
    PropDef("show", "xlink:show"),
    PropDef("actuate", "xlink:actuate"),
)

_tag class-attribute instance-attribute

_tag = 'draw:fill-image'

actuate instance-attribute

actuate = actuate

display_name instance-attribute

display_name = display_name

family instance-attribute

family = ''

height instance-attribute

height = height

name instance-attribute

name = name

show instance-attribute

show = show

url instance-attribute

url = url

width instance-attribute

width = width
xlink_type = xlink_type

__init__

__init__(
    name: str | None = None,
    display_name: str | None = None,
    height: str | None = None,
    width: str | None = None,
    url: str = "",
    xlink_type: str = "simple",
    show: str = "embed",
    actuate: str = "onLoad",
    **kwargs: Any,
) -> None

Initialize a DrawFillImage, “draw:fill-image”.

The draw:fill-image element specifies a link to a bitmap resource. Fill images are not available as automatic styles and are typically used within the office:styles element.

Parameters:

Name Type Description Default
name str | None

The internal name of the fill image.

None
display_name str | None

The display name of the fill image.

None
height str | None

The height of the fill image (e.g., “10cm”).

None
width str | None

The width of the fill image (e.g., “15cm”).

None
url str

The URL or internal path of the image.

''
xlink_type str

The XLink type, usually “simple”.

'simple'
show str

How the image should be shown, usually “embed”.

'embed'
actuate str

When the image should be loaded, usually “onLoad”.

'onLoad'
**kwargs Any

Additional keyword arguments for the parent DrawImage class.

{}
Source code in odfdo/image.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
def __init__(
    self,
    name: str | None = None,
    display_name: str | None = None,
    height: str | None = None,
    width: str | None = None,
    url: str = "",
    xlink_type: str = "simple",
    show: str = "embed",
    actuate: str = "onLoad",
    **kwargs: Any,
) -> None:
    """Initialize a DrawFillImage, "draw:fill-image".

    The `draw:fill-image` element specifies a link to a bitmap resource.
    Fill images are not available as automatic styles and are typically
    used within the `office:styles` element.

    Args:
        name: The internal name of the fill image.
        display_name: The display name of the fill image.
        height: The height of the fill image (e.g., "10cm").
        width: The width of the fill image (e.g., "15cm").
        url: The URL or internal path of the image.
        xlink_type: The XLink type, usually "simple".
        show: How the image should be shown, usually "embed".
        actuate: When the image should be loaded, usually "onLoad".
        **kwargs: Additional keyword arguments for the parent `DrawImage` class.
    """
    super().__init__(**kwargs)
    if self._do_init:
        self.name = name
        self.display_name = display_name
        self.height = height
        self.width = width
        self.url = url
        self.xlink_type = xlink_type
        self.show = show
        self.actuate = actuate
    self.family = ""

__str__

__str__() -> str
Source code in odfdo/image.py
157
158
def __str__(self) -> str:
    return f"({self.url})"

DrawImage

Bases: ListMixin, Element

An ODF image, “draw:image”.

The “draw:image” element represents an image. An image can be either a link to an external resource or most often embedded into the document.

Methods:

Name Description
__init__

Initialize an ODF image, “draw:image”.

__str__

Attributes:

Name Type Description
actuate
filter_name
mime_type
show
url
xlink_type
xml_id
Source code in odfdo/image.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
class DrawImage(ListMixin, Element):
    """An ODF image, "draw:image".

    The "draw:image" element represents an image. An image can be either a link
    to an external resource or most often embedded into the document.
    """

    _tag = "draw:image"
    _properties: tuple[PropDef | PropDefBool, ...] = (
        PropDef("url", "xlink:href"),
        PropDef("xlink_type", "xlink:type"),
        PropDef("show", "xlink:show"),
        PropDef("actuate", "xlink:actuate"),
        PropDef("filter_name", "draw:filter-name"),
        PropDef("mime_type", "draw:mime-type"),
        PropDef("xml_id", "xml:id"),
    )

    def __init__(
        self,
        url: str = "",
        xlink_type: str = "simple",
        show: str = "embed",
        actuate: str = "onLoad",
        filter_name: str | None = None,
        mime_type: str | None = None,
        xml_id: str | None = None,
        **kwargs: Any,
    ) -> None:
        """Initialize an ODF image, "draw:image".

        The `draw:image` element represents an image. It can be a link to an
        external resource or, more commonly, embedded within the document.

        When an image is embedded, the `url` parameter should be a reference
        to the local document, typically obtained by adding the image file
        (e.g., `url = document.add_file(image_path)`).

        Warning: Image elements should generally be stored within a `draw:frame`
        element (see `Frame` class).

        Args:
            url: The URL or internal path of the image.
            xlink_type: The XLink type, usually "simple".
            show: How the image should be shown, usually "embed".
            actuate: When the image should be loaded, usually "onLoad".
            filter_name: An optional filter name to apply to the image.
            mime_type: The MIME type of the image's content.
            xml_id: The unique XML ID.
            **kwargs: Additional keyword arguments for the parent `Element` class.
        """
        super().__init__(**kwargs)
        if self._do_init:
            self.url = url
            self.xlink_type = xlink_type
            self.show = show
            self.actuate = actuate
            self.filter_name = filter_name
            self.mime_type = mime_type
            self.xml_id = xml_id

    def __str__(self) -> str:
        return f"({self.url})"

_properties class-attribute instance-attribute

_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef("url", "xlink:href"),
    PropDef("xlink_type", "xlink:type"),
    PropDef("show", "xlink:show"),
    PropDef("actuate", "xlink:actuate"),
    PropDef("filter_name", "draw:filter-name"),
    PropDef("mime_type", "draw:mime-type"),
    PropDef("xml_id", "xml:id"),
)

_tag class-attribute instance-attribute

_tag = 'draw:image'

actuate instance-attribute

actuate = actuate

filter_name instance-attribute

filter_name = filter_name

mime_type instance-attribute

mime_type = mime_type

show instance-attribute

show = show

url instance-attribute

url = url
xlink_type = xlink_type

xml_id instance-attribute

xml_id = xml_id

__init__

__init__(
    url: str = "",
    xlink_type: str = "simple",
    show: str = "embed",
    actuate: str = "onLoad",
    filter_name: str | None = None,
    mime_type: str | None = None,
    xml_id: str | None = None,
    **kwargs: Any,
) -> None

Initialize an ODF image, “draw:image”.

The draw:image element represents an image. It can be a link to an external resource or, more commonly, embedded within the document.

When an image is embedded, the url parameter should be a reference to the local document, typically obtained by adding the image file (e.g., url = document.add_file(image_path)).

Warning: Image elements should generally be stored within a draw:frame element (see Frame class).

Parameters:

Name Type Description Default
url str

The URL or internal path of the image.

''
xlink_type str

The XLink type, usually “simple”.

'simple'
show str

How the image should be shown, usually “embed”.

'embed'
actuate str

When the image should be loaded, usually “onLoad”.

'onLoad'
filter_name str | None

An optional filter name to apply to the image.

None
mime_type str | None

The MIME type of the image’s content.

None
xml_id str | None

The unique XML ID.

None
**kwargs Any

Additional keyword arguments for the parent Element class.

{}
Source code in odfdo/image.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def __init__(
    self,
    url: str = "",
    xlink_type: str = "simple",
    show: str = "embed",
    actuate: str = "onLoad",
    filter_name: str | None = None,
    mime_type: str | None = None,
    xml_id: str | None = None,
    **kwargs: Any,
) -> None:
    """Initialize an ODF image, "draw:image".

    The `draw:image` element represents an image. It can be a link to an
    external resource or, more commonly, embedded within the document.

    When an image is embedded, the `url` parameter should be a reference
    to the local document, typically obtained by adding the image file
    (e.g., `url = document.add_file(image_path)`).

    Warning: Image elements should generally be stored within a `draw:frame`
    element (see `Frame` class).

    Args:
        url: The URL or internal path of the image.
        xlink_type: The XLink type, usually "simple".
        show: How the image should be shown, usually "embed".
        actuate: When the image should be loaded, usually "onLoad".
        filter_name: An optional filter name to apply to the image.
        mime_type: The MIME type of the image's content.
        xml_id: The unique XML ID.
        **kwargs: Additional keyword arguments for the parent `Element` class.
    """
    super().__init__(**kwargs)
    if self._do_init:
        self.url = url
        self.xlink_type = xlink_type
        self.show = show
        self.actuate = actuate
        self.filter_name = filter_name
        self.mime_type = mime_type
        self.xml_id = xml_id

__str__

__str__() -> str
Source code in odfdo/image.py
94
95
def __str__(self) -> str:
    return f"({self.url})"

DrawMarker

Bases: Element

A marker, “draw:marker”, which is used to draw polygons at the start or end point of a stroke depending on whether it is referenced by a “draw:marker-start” or “draw:marker-end” attribute.

Marker geometry is defined by a svg:d attribute.

The “draw:marker” element is usable within the “office:styles”.

Methods:

Name Description
__init__

Create a draw marker “draw:marker”.

Attributes:

Name Type Description
display_name
family
name
svg_d
view_box
Source code in odfdo/image.py
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
class DrawMarker(Element):
    """A marker, "draw:marker", which is used to draw polygons at the start
    or end point of a stroke depending on whether it is referenced by a
    "draw:marker-start" or "draw:marker-end" attribute.

    Marker geometry is defined by a svg:d attribute.

    The "draw:marker" element is usable within the "office:styles"."""

    _tag = "draw:marker"
    _properties: tuple[PropDef | PropDefBool, ...] = (
        PropDef("name", "draw:name"),
        PropDef("display_name", "draw:display-name"),
        PropDef("svg_d", "svg:d"),
        PropDef("view_box", "svg:viewBox"),
    )

    def __init__(
        self,
        name: str | None = None,
        display_name: str | None = None,
        svg_d: str | None = None,
        view_box: str | None = None,
        **kwargs: Any,
    ) -> None:
        """Create a draw marker "draw:marker".

        Args:
            name: The internal name of the fill image.
            display_name: The display name of the fill image.
            svg_d: A path data.
            view_box: The rectangle in a local coordinates system used by the
                points.
            **kwargs: Additional keyword arguments for the `DrawMarker` class.
        """
        super().__init__(**kwargs)
        if self._do_init:
            if name:
                self.name = name
            if display_name:
                self.display_name = display_name
            if svg_d:
                self.svg_d = svg_d
            if view_box:
                self.view_box = view_box
        # false family for easier parsing:
        self.family = ""

_properties class-attribute instance-attribute

_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef("name", "draw:name"),
    PropDef("display_name", "draw:display-name"),
    PropDef("svg_d", "svg:d"),
    PropDef("view_box", "svg:viewBox"),
)

_tag class-attribute instance-attribute

_tag = 'draw:marker'

display_name instance-attribute

display_name = display_name

family instance-attribute

family = ''

name instance-attribute

name = name

svg_d instance-attribute

svg_d = svg_d

view_box instance-attribute

view_box = view_box

__init__

__init__(
    name: str | None = None,
    display_name: str | None = None,
    svg_d: str | None = None,
    view_box: str | None = None,
    **kwargs: Any,
) -> None

Create a draw marker “draw:marker”.

Parameters:

Name Type Description Default
name str | None

The internal name of the fill image.

None
display_name str | None

The display name of the fill image.

None
svg_d str | None

A path data.

None
view_box str | None

The rectangle in a local coordinates system used by the points.

None
**kwargs Any

Additional keyword arguments for the DrawMarker class.

{}
Source code in odfdo/image.py
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
def __init__(
    self,
    name: str | None = None,
    display_name: str | None = None,
    svg_d: str | None = None,
    view_box: str | None = None,
    **kwargs: Any,
) -> None:
    """Create a draw marker "draw:marker".

    Args:
        name: The internal name of the fill image.
        display_name: The display name of the fill image.
        svg_d: A path data.
        view_box: The rectangle in a local coordinates system used by the
            points.
        **kwargs: Additional keyword arguments for the `DrawMarker` class.
    """
    super().__init__(**kwargs)
    if self._do_init:
        if name:
            self.name = name
        if display_name:
            self.display_name = display_name
        if svg_d:
            self.svg_d = svg_d
        if view_box:
            self.view_box = view_box
    # false family for easier parsing:
    self.family = ""