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

Skip to content

Commit 01a61d0

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

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

docx/image/image.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ def from_file(cls, image_descriptor):
5454
filename = None
5555
return cls._from_stream(stream, blob, filename)
5656

57+
@property
58+
def blob(self):
59+
"""
60+
The bytes of the image 'file'
61+
"""
62+
return self._blob
63+
5764
@property
5865
def content_type(self):
5966
"""

tests/image/test_image.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ def it_can_construct_from_an_image_stream(self, from_stream_fixture):
6060
Image__init_.assert_called_once_with(blob_, filename_, image_header_)
6161
assert isinstance(image, Image)
6262

63+
def it_provides_access_to_the_image_blob(self):
64+
blob = b'foobar'
65+
image = Image(blob, None, None)
66+
assert image.blob == blob
67+
6368
def it_knows_the_image_content_type(self, content_type_fixture):
6469
image_header_, content_type = content_type_fixture
6570
image = Image(None, None, image_header_)

0 commit comments

Comments
 (0)