Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a8faaeb

Browse files
author
Steve Canny
committed
img: add Image.filename
1 parent 01a61d0 commit a8faaeb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docx/image/image.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ def ext(self):
7979
"""
8080
return os.path.splitext(self._filename)[1][1:]
8181

82+
@property
83+
def filename(self):
84+
"""
85+
Original image file name, if loaded from disk, or a generic filename
86+
if loaded from an anonymous stream.
87+
"""
88+
return self._filename
89+
8290
@property
8391
def px_width(self):
8492
"""

tests/image/test_image.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ def it_knows_the_image_dimensions(self, dimensions_fixture):
7676
assert image.px_width == px_width
7777
assert image.px_height == px_height
7878

79+
def it_knows_the_image_filename(self):
80+
filename = 'foobar.png'
81+
image = Image(None, filename, None)
82+
assert image.filename == filename
83+
7984
def it_knows_the_image_filename_extension(self):
8085
image = Image(None, 'foobar.png', None)
8186
assert image.ext == 'png'

0 commit comments

Comments
 (0)