Skip to content

Commit 395b48f

Browse files
author
Steve Canny
committed
shp: fix python-openxml#94 picture prints at wrong size
1 parent 4008ab2 commit 395b48f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

docx/shape.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ def height(self):
6666

6767
@height.setter
6868
def height(self, cy):
69-
assert isinstance(cy, int)
70-
assert 0 < cy
7169
self._inline.extent.cy = cy
70+
self._inline.graphic.graphicData.pic.spPr.cy = cy
7271

7372
@property
7473
def type(self):
@@ -100,6 +99,5 @@ def width(self):
10099

101100
@width.setter
102101
def width(self, cx):
103-
assert isinstance(cx, int)
104-
assert 0 < cx
105102
self._inline.extent.cx = cx
103+
self._inline.graphic.graphicData.pic.spPr.cx = cx

tests/test_shape.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ def dimensions_get_fixture(self):
112112
@pytest.fixture
113113
def dimensions_set_fixture(self):
114114
inline_cxml, new_cx, new_cy, expected_cxml = (
115-
'wp:inline/wp:extent{cx=333, cy=666}', 444, 888,
116-
'wp:inline/wp:extent{cx=444, cy=888}'
115+
'wp:inline/(wp:extent{cx=333,cy=666},a:graphic/a:graphicData/'
116+
'pic:pic/pic:spPr/a:xfrm/a:ext{cx=333,cy=666})',
117+
444, 888,
118+
'wp:inline/(wp:extent{cx=444,cy=888},a:graphic/a:graphicData/'
119+
'pic:pic/pic:spPr/a:xfrm/a:ext{cx=444,cy=888})'
117120
)
118121
inline_shape = InlineShape(element(inline_cxml))
119122
expected_xml = xml(expected_cxml)

0 commit comments

Comments
 (0)