fix: scale signature images to fill signature fields

The field renderer decreased large signature images to the field size, but it did not
increase small images. Thus a low-resolution image, for example an upload from a different
tool, showed at its native pixel size and was too small. This change removes the cap on the
scale factor in the Konva field renderer and in the v1 and legacy PDF insert paths. The image
scales in the two directions to fill the field, and the aspect ratio stays the same.
This commit is contained in:
ephraimduncan
2026-08-11 15:37:40 +00:00
parent 962cffc9f5
commit f9a4cc42fd
3 changed files with 3 additions and 3 deletions
@@ -135,7 +135,7 @@ export const insertFieldInPDFV1 = async (pdf: PDFDocument, field: FieldWithSigna
let imageWidth = image.width;
let imageHeight = image.height;
const scalingFactor = Math.min(fieldWidth / imageWidth, fieldHeight / imageHeight, 1);
const scalingFactor = Math.min(fieldWidth / imageWidth, fieldHeight / imageHeight);
imageWidth = imageWidth * scalingFactor;
imageHeight = imageHeight * scalingFactor;
@@ -128,7 +128,7 @@ export const legacy_insertFieldInPDF = async (pdf: PDFDocument, field: FieldWith
let imageWidth = image.width;
let imageHeight = image.height;
const scalingFactor = Math.min(fieldWidth / imageWidth, fieldHeight / imageHeight, 1);
const scalingFactor = Math.min(fieldWidth / imageWidth, fieldHeight / imageHeight);
imageWidth = imageWidth * scalingFactor;
imageHeight = imageHeight * scalingFactor;
@@ -23,7 +23,7 @@ const getImageDimensions = (img: HTMLImageElement, fieldWidth: number, fieldHeig
let imageWidth = img.width;
let imageHeight = img.height;
const scalingFactor = Math.min(fieldWidth / imageWidth, fieldHeight / imageHeight, 1);
const scalingFactor = Math.min(fieldWidth / imageWidth, fieldHeight / imageHeight);
imageWidth = imageWidth * scalingFactor;
imageHeight = imageHeight * scalingFactor;