Skip to content

Commit dade3c3

Browse files
author
Steve Canny
committed
img: add Tiff.horz_dpi and .vert_dpi
1 parent 02b4a63 commit dade3c3

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

docx/image/tiff.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ def from_stream(cls, stream, blob, filename):
3838
vert_dpi = parser.vert_dpi
3939
return cls(blob, filename, px_width, px_height, horz_dpi, vert_dpi)
4040

41+
@property
42+
def horz_dpi(self):
43+
"""
44+
The intended print density of the image's pixels along the x-axis
45+
"""
46+
return self._horz_dpi
47+
48+
@property
49+
def vert_dpi(self):
50+
"""
51+
The intended print density of the image's pixels along the y-axis
52+
"""
53+
return self._vert_dpi
54+
4155

4256
class _TiffParser(object):
4357
"""

tests/image/test_tiff.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def it_knows_its_content_type(self):
4040
tiff = Tiff(None, None, None, None, None, None)
4141
assert tiff.content_type == MIME_TYPE.TIFF
4242

43+
def it_knows_the_horz_and_vert_dpi_of_the_tiff_image(self):
44+
horz_dpi, vert_dpi = 42, 24
45+
tiff = Tiff(None, None, None, None, horz_dpi, vert_dpi)
46+
assert tiff.horz_dpi == horz_dpi
47+
assert tiff.vert_dpi == vert_dpi
48+
4349
# fixtures -------------------------------------------------------
4450

4551
@pytest.fixture

0 commit comments

Comments
 (0)