@@ -87,19 +87,27 @@ def px_height(self) -> int:
8787
8888 @property
8989 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.
9390 """
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
9599
96100 @property
97101 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.
101102 """
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
103111
104112 @property
105113 def width (self ) -> Inches :
@@ -219,16 +227,24 @@ def px_height(self):
219227
220228 @property
221229 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.
225230 """
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
227239
228240 @property
229241 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.
233242 """
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