使用 Jimp 拼接多个 png

问题描述

我需要将多个png拼接成一个长png,我相信我可以使用Jimp的blit方法

// blit the image with another Jimp image at x,y,optionally cropped.
image.blit( src,x,[srcx,srcy,srcw,srch] );

我的问题是,如何循环所有 png 并将当前 png 附加到前一个 png 的末尾?例如,它们都在同一个文件夹中,文件名为 img-1、img-2 ... img-10。而且它们的大小不一定相同。这就是我的想法,任何建议将不胜感激!

// This is dummy code

const bg = white_background
bg.width = Math.max(img-1...img-10 width)
bg.height = sum(img-1...img-10 height)

for (let i=0;i<imgs.length;i++) {
    if(i=0) bg.blit(img,0)
    else bg.blit(img,imgs[i-1].width,imgs[i-1].height)
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)