@@ -87,19 +87,27 @@ def px_height(self) -> int:
87
87
88
88
@property
89
89
def horz_dpi (self ) -> int :
90
- """Integer dots per inch for the width of this image.
91
-
92
- Defaults to 72 when not present in the file, as is often the case.
93
90
"""
94
- return self ._image_header .horz_dpi
91
+ Horizontal DPI reported for this image. Returns the header value
92
+ unless it is `None` **or** `0`, in which case it defaults to
93
+ 72 dpi, matching Word's internal assumption.
94
+ """
95
+ dpi = self ._image_header .horz_dpi
96
+ if dpi in (None , 0 ):
97
+ return 72
98
+ return dpi
95
99
96
100
@property
97
101
def vert_dpi (self ) -> int :
98
- """Integer dots per inch for the height of this image.
99
-
100
- Defaults to 72 when not present in the file, as is often the case.
101
102
"""
102
- return self ._image_header .vert_dpi
103
+ Vertical DPI reported for this image. Returns the header value
104
+ unless it is `None` **or** `0`, in which case it defaults to
105
+ 72 dpi, matching Word's internal assumption.
106
+ """
107
+ dpi = self ._image_header .vert_dpi
108
+ if dpi in (None , 0 ):
109
+ return 72
110
+ return dpi
103
111
104
112
@property
105
113
def width (self ) -> Inches :
@@ -219,16 +227,24 @@ def px_height(self):
219
227
220
228
@property
221
229
def horz_dpi (self ):
222
- """Integer dots per inch for the width of this image.
223
-
224
- Defaults to 72 when not present in the file, as is often the case.
225
230
"""
226
- return self ._horz_dpi
231
+ Horizontal DPI reported for this image. Returns the header value
232
+ unless it is `None` **or** `0`, in which case it defaults to
233
+ 72 dpi, matching Word's internal assumption.
234
+ """
235
+ dpi = self ._horz_dpi
236
+ if dpi in (None , 0 ):
237
+ return 72
238
+ return dpi
227
239
228
240
@property
229
241
def vert_dpi (self ):
230
- """Integer dots per inch for the height of this image.
231
-
232
- Defaults to 72 when not present in the file, as is often the case.
233
242
"""
234
- return self ._vert_dpi
243
+ Vertical DPI reported for this image. Returns the header value
244
+ unless it is `None` **or** `0`, in which case it defaults to
245
+ 72 dpi, matching Word's internal assumption.
246
+ """
247
+ dpi = self ._vert_dpi
248
+ if dpi in (None , 0 ):
249
+ return 72
250
+ return dpi
0 commit comments