feat: 优化

main
lichaojun 1 year ago
parent 5821af51bc
commit 86c29cffcf

@ -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,
},
};

@ -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); // 根据比例计算高度

Loading…
Cancel
Save