From aed831fc8ce1cc42e82d3c7ee6d5f9f7831fad7f Mon Sep 17 00:00:00 2001 From: Poker Design Developer Date: Thu, 4 Jun 2026 22:09:08 +0800 Subject: [PATCH] fix: joker images stretch to fill body area equally for big/small --- backend/apps/exports/utils.py | 2 +- frontend/src/utils/cardRenderer.js | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/backend/apps/exports/utils.py b/backend/apps/exports/utils.py index ebb474a..d5eb5de 100644 --- a/backend/apps/exports/utils.py +++ b/backend/apps/exports/utils.py @@ -331,7 +331,7 @@ def draw_joker(canvas, design, which, project, card_key, asset): offset_y = int(body_h * image_dy) img_copy = asset.copy() - img_copy.thumbnail((body_w, half_h), Image.LANCZOS) + img_copy = img_copy.resize((body_w, half_h), Image.LANCZOS) if image_scale != 1: sw = max(1, int(img_copy.width * image_scale)) sh = max(1, int(img_copy.height * image_scale)) diff --git a/frontend/src/utils/cardRenderer.js b/frontend/src/utils/cardRenderer.js index 3445fe7..dbb75f7 100644 --- a/frontend/src/utils/cardRenderer.js +++ b/frontend/src/utils/cardRenderer.js @@ -280,19 +280,11 @@ async function drawJokerBody(ctx, w, h, which, design, project) { if (img && img.complete && img.naturalWidth) { const halfH = bodyH / 2 - const imgRatio = img.naturalWidth / img.naturalHeight - const target = bodyW / halfH - let drawW, drawH - if (imgRatio > target) { - drawW = bodyW; drawH = bodyW / imgRatio - } else { - drawH = halfH; drawW = halfH * imgRatio - } const imageDx = Number(design.image_dx) || 0 const imageDy = Number(design.image_dy) || 0 const imageScale = Number(design.image_scale) || 1 - const finalW = Math.max(1, drawW * imageScale) - const finalH = Math.max(1, drawH * imageScale) + const finalW = Math.max(1, bodyW * imageScale) + const finalH = Math.max(1, halfH * imageScale) const offsetX = bodyW * imageDx const offsetY = bodyH * imageDy const topX = padX + offsetX + (bodyW - finalW) / 2