@@ -91,8 +91,11 @@ def replacedbox_layout(box):
91
91
position = box .style ['object_position' ]
92
92
93
93
image = box .replacement
94
- iwidth , iheight = image .get_intrinsic_size (
94
+ intrinsic_width , intrinsic_height = image .get_intrinsic_size (
95
95
box .style ['image_resolution' ], box .style ['font_size' ])
96
+ if None in (intrinsic_width , intrinsic_height ):
97
+ intrinsic_width , intrinsic_height = contain_constraint_image_sizing (
98
+ box .width , box .height , box .replacement .intrinsic_ratio )
96
99
97
100
if object_fit == 'fill' :
98
101
draw_width , draw_height = box .width , box .height
@@ -105,11 +108,11 @@ def replacedbox_layout(box):
105
108
box .width , box .height , box .replacement .intrinsic_ratio )
106
109
else :
107
110
assert object_fit == 'none' , object_fit
108
- draw_width , draw_height = iwidth , iheight
111
+ draw_width , draw_height = intrinsic_width , intrinsic_height
109
112
110
113
if object_fit == 'scale-down' :
111
- draw_width = min (draw_width , iwidth )
112
- draw_height = min (draw_height , iheight )
114
+ draw_width = min (draw_width , intrinsic_width )
115
+ draw_height = min (draw_height , intrinsic_height )
113
116
114
117
origin_x , position_x , origin_y , position_y = position [0 ]
115
118
ref_x = box .width - draw_width
0 commit comments