1717from docx .image .png import Png
1818from docx .image .tiff import Tiff
1919from docx .opc .constants import CONTENT_TYPE as CT
20+ from docx .shared import Length
2021
2122from ..unitutil .file import test_file
2223from ..unitutil .mock import (
@@ -71,7 +72,7 @@ def it_knows_the_image_content_type(self, content_type_fixture):
7172 image = Image (None , None , image_header_ )
7273 assert image .content_type == content_type
7374
74- def it_knows_the_image_dimensions (self , dimensions_fixture ):
75+ def it_knows_the_image_px_dimensions (self , dimensions_fixture ):
7576 image_header_ , px_width , px_height = dimensions_fixture
7677 image = Image (None , None , image_header_ )
7778 assert image .px_width == px_width
@@ -83,6 +84,12 @@ def it_knows_the_horz_and_vert_dpi_of_the_image(self, dpi_fixture):
8384 assert image .horz_dpi == horz_dpi
8485 assert image .vert_dpi == vert_dpi
8586
87+ def it_knows_the_image_native_size (self , size_fixture ):
88+ image , width , height = size_fixture
89+ assert (image .width , image .height ) == (width , height )
90+ assert isinstance (image .width , Length )
91+ assert isinstance (image .height , Length )
92+
8693 def it_knows_the_image_filename (self ):
8794 filename = 'foobar.png'
8895 image = Image (None , filename , None )
@@ -182,6 +189,13 @@ def known_image_fixture(self, request):
182189 image_filename , characteristics = cases [request .param ]
183190 return image_filename , characteristics
184191
192+ @pytest .fixture
193+ def size_fixture (self , image_header_ ):
194+ image_header_ .px_width , image_header_ .px_height = 150 , 75
195+ image_header_ .horz_dpi , image_header_ .vert_dpi = 72 , 200
196+ image = Image (None , None , image_header_ )
197+ return image , 1905000 , 342900
198+
185199 # fixture components ---------------------------------------------
186200
187201 @pytest .fixture
0 commit comments