From 69680fede7de62f503a59efbbd8aa058b8e50395 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 16 Sep 2023 20:36:00 +0900 Subject: [PATCH 1/2] fix: thumbnail ratio fix for mixed ratio images --- web/scripts/app.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web/scripts/app.js b/web/scripts/app.js index 4beaf03a..84090764 100644 --- a/web/scripts/app.js +++ b/web/scripts/app.js @@ -532,7 +532,17 @@ export class ComfyApp { } } this.imageRects.push([x, y, cellWidth, cellHeight]); - ctx.drawImage(img, x, y, cellWidth, cellHeight); + + let wratio = cellWidth/img.width; + let hratio = cellHeight/img.height; + var ratio = Math.min(wratio, hratio); + + let imgHeight = ratio * img.height; + let imgY = row * cellHeight + shiftY + (cellHeight - imgHeight)/2; + let imgWidth = ratio * img.width; + let imgX = col * cellWidth + shiftX + (cellWidth - imgWidth)/2; + + ctx.drawImage(img, imgX, imgY, imgWidth, imgHeight); ctx.filter = "none"; } From 4d5e057bb2e32117c945cc9dfe8039dad2329297 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 16 Sep 2023 20:37:27 +0900 Subject: [PATCH 2/2] fix indent --- web/scripts/app.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/scripts/app.js b/web/scripts/app.js index 84090764..f0bb8640 100644 --- a/web/scripts/app.js +++ b/web/scripts/app.js @@ -533,14 +533,14 @@ export class ComfyApp { } this.imageRects.push([x, y, cellWidth, cellHeight]); - let wratio = cellWidth/img.width; - let hratio = cellHeight/img.height; - var ratio = Math.min(wratio, hratio); + let wratio = cellWidth/img.width; + let hratio = cellHeight/img.height; + var ratio = Math.min(wratio, hratio); - let imgHeight = ratio * img.height; - let imgY = row * cellHeight + shiftY + (cellHeight - imgHeight)/2; - let imgWidth = ratio * img.width; - let imgX = col * cellWidth + shiftX + (cellWidth - imgWidth)/2; + let imgHeight = ratio * img.height; + let imgY = row * cellHeight + shiftY + (cellHeight - imgHeight)/2; + let imgWidth = ratio * img.width; + let imgX = col * cellWidth + shiftX + (cellWidth - imgWidth)/2; ctx.drawImage(img, imgX, imgY, imgWidth, imgHeight); ctx.filter = "none";