Skip to content

Commit 07f8d88

Browse files
committed
Fix getCorrectedImageSize method
1 parent 1c35c3a commit 07f8d88

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/helper_survey.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,8 @@ export class SurveyHelper {
703703
}
704704
}
705705
else if(imageSize && imageSize.height && imageSize.width) {
706-
heightPt = SurveyHelper.parseWidth(imageSize.height.toString(), SurveyHelper.getPageAvailableWidth(controller), 1, 'px');
707-
widthPt = SurveyHelper.parseWidth(imageSize.width.toString(), SurveyHelper.getPageAvailableWidth(controller), 1, 'px');
706+
heightPt = Math.min(imageSize.height, SurveyHelper.getPageAvailableWidth(controller));
707+
widthPt = Math.min(imageSize.width, SurveyHelper.getPageAvailableWidth(controller));
708708
}
709709
}
710710
return { width: widthPt || defaultWidthPt || 0, height: heightPt || defaultHeightPt || 0 };

tests/flat_file.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ test('Check one image 16x16px file', async () => {
164164
controller.margins.left += controller.unitWidth;
165165
const assumeFile: IRect = {
166166
xLeft: controller.leftTopPoint.xLeft,
167-
xRight: controller.leftTopPoint.xLeft + SurveyHelper.pxToPt(imageSize.width),
167+
xRight: controller.leftTopPoint.xLeft + imageSize.width,
168168
yTop: controller.leftTopPoint.yTop,
169-
yBot: controller.leftTopPoint.yTop + SurveyHelper.pxToPt(imageSize.height) +
169+
yBot: controller.leftTopPoint.yTop + imageSize.height +
170170
controller.unitHeight * (1.0 + FlatFile.IMAGE_GAP_SCALE)
171171
};
172172
TestHelper.equalRect(expect, flats[0][0], assumeFile);
@@ -204,7 +204,7 @@ test('Check one image 16x16px file shorter than text', async () => {
204204
xLeft: controller.leftTopPoint.xLeft,
205205
xRight: controller.leftTopPoint.xLeft + controller.measureText(json.elements[0].defaultValue[0].name).width,
206206
yTop: controller.leftTopPoint.yTop,
207-
yBot: controller.leftTopPoint.yTop + SurveyHelper.pxToPt(imageSize.height) +
207+
yBot: controller.leftTopPoint.yTop + imageSize.height +
208208
controller.unitHeight * (1.0 + FlatFile.IMAGE_GAP_SCALE)
209209
};
210210
TestHelper.equalRect(expect, flats[0][0], assumeFile);

0 commit comments

Comments
 (0)