From 86c29cffcf405d29a6a8d95821c869d455dcff46 Mon Sep 17 00:00:00 2001 From: lichaojun Date: Fri, 22 Nov 2024 00:15:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 4 ++-- src/img_merge.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config/index.js b/config/index.js index d962395..bbaa5d6 100644 --- a/config/index.js +++ b/config/index.js @@ -42,7 +42,7 @@ const config = { }, merge: { // 每行图片的个数 - row: 3, + row: 2, //画布背景颜色 bgColor: 'rgb(211, 211, 211)', //画布宽度 @@ -53,7 +53,7 @@ const config = { padding: 3, }, exportAdImg: { - pptPath: '/Users/minya/Desktop/test/1.pptx', + pptPath: 'E:/商品资料汇总/商品资料(1151-1200)/ppt1155-拒绝拖延/2.pptx', column: 3, }, }; diff --git a/src/img_merge.js b/src/img_merge.js index a475884..299a081 100644 --- a/src/img_merge.js +++ b/src/img_merge.js @@ -26,6 +26,10 @@ if (!fs.existsSync(previewDir)) { } async function stitchImages(imagePaths, { row, bgColor, width, margin, padding }, outputName) { + if (imagePaths.length >= 25) { + row = 3; // 超过25张图片时,每行最多3张图片 + } + // 获取第一张图片的信息 const firstImageInfo = await sharp(imagePaths[0]).metadata(); const firstImageHeight = Math.floor((firstImageInfo.height / firstImageInfo.width) * width); // 根据比例计算高度