From df8707776c8e18da9c0b5e18e6e6801805b591be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Fri, 27 Feb 2026 17:22:19 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[esign]=20=EC=84=9C=EB=AA=85/=EB=8F=84?= =?UTF-8?q?=EC=9E=A5=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=9B=90=EB=B3=B8=20?= =?UTF-8?q?=EB=B9=84=EC=9C=A8=20=EC=9C=A0=EC=A7=80=ED=95=98=EC=97=AC=20PDF?= =?UTF-8?q?=20=ED=95=A9=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - overlayImage()에서 원본 이미지 가로세로 비율 계산 - 필드 영역 내 contain 방식 배치 (비율 유지 + 중앙 정렬) - getimagesize 실패 시 기존 방식 폴백 --- app/Services/ESign/PdfSignatureService.php | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/app/Services/ESign/PdfSignatureService.php b/app/Services/ESign/PdfSignatureService.php index 0c4a1034..2b0d5c52 100644 --- a/app/Services/ESign/PdfSignatureService.php +++ b/app/Services/ESign/PdfSignatureService.php @@ -232,7 +232,31 @@ private function overlayImage(Fpdi $pdf, EsignSignField $field, float $x, float return; } - $pdf->Image($imagePath, $x, $y, $w, $h, 'PNG'); + // 원본 이미지 비율 유지: 필드 영역 내에 contain 방식으로 배치 + $imgSize = @getimagesize($imagePath); + if ($imgSize && $imgSize[0] > 0 && $imgSize[1] > 0) { + $imgRatio = $imgSize[0] / $imgSize[1]; // 원본 가로/세로 비율 + $fieldRatio = $w / $h; + + if ($imgRatio > $fieldRatio) { + // 이미지가 필드보다 가로로 넓음 → 가로 맞춤, 세로 축소 + $renderW = $w; + $renderH = $w / $imgRatio; + } else { + // 이미지가 필드보다 세로로 높음 → 세로 맞춤, 가로 축소 + $renderH = $h; + $renderW = $h * $imgRatio; + } + + // 필드 영역 중앙에 배치 + $renderX = $x + ($w - $renderW) / 2; + $renderY = $y + ($h - $renderH) / 2; + + $pdf->Image($imagePath, $renderX, $renderY, $renderW, $renderH, 'PNG'); + } else { + // 이미지 크기 읽기 실패 시 기존 방식 유지 + $pdf->Image($imagePath, $x, $y, $w, $h, 'PNG'); + } } /**