介绍nodejs实现图片拼接插件功能:1、横向拼接两张图片;2、纵向拼接两张图片;3、批量拼接;4、自定义拼接矩阵等。
依赖引入
const consoleInput = require('@jyeontu/img-concat'); const ImgConcatClass = new ImgConcat();
1、横向拼接两张图片
const consoleInput = require('@jyeontu/img-concat'); const ImgConcatClass = new ImgConcat(); const p1 = { left:'.\\img\\n1.jpg', right:'.\\img\\n2.jpg', target:'.\\longImg' } // 横向拼接两张图片 ImgConcatClass.collapseHorizontal(p1).then(res=>{ console.log(`拼接完成,图片路径为${res}`); });
2、纵向拼接两张图片
const consoleInput = require('@jyeontu/img-concat'); const ImgConcatClass = new ImgConcat(); const p1 = { left:'.\\img\\n1.jpg', right:'.\\img\\n2.jpg', target:'.\\longImg' } //纵向拼接两张图片 ImgConcatClass.collapseVertical(p1).then(res=>{ console.log(`拼接完成,图片路径为${res}`); });
3、批量拼接
//3.1横向拼接长图 const consoleInput = require('@jyeontu/img-concat'); const ImgConcatClass = new ImgConcat(); const p = { folderPath:'.\\img', //资源目录 targetFolder:'.\\longImg', //转换后图片存放目录 direction:'y' //拼接方向,y为横向,n为纵向 } // 拼接目录下的所有图片 ImgConcatClass.concatAll(p).then(res=>{ console.log(`拼接完成,图片路径为${res}`); }) //3.2纵向拼接长图 const consoleInput = require('@jyeontu/img-concat'); const ImgConcatClass = new ImgConcat(); const p = { folderPath:'.\\img', //资源目录 targetFolder:'.\\longImg', //转换后图片存放目录 direction:'n' //拼接方向,y为横向,n为纵向 } // 拼接目录下的所有图片 ImgConcatClass.concatAll(p).then(res=>{ console.log(`拼接完成,图片路径为${res}`); })
4、自定义拼接矩阵
const consoleInput = require('@jyeontu/img-concat'); const ImgConcatClass = new ImgConcat(); const p = { shape:[['.\\img\\n1.jpg','.\\img\\white.jpg','.\\img\\n2.jpg'], ['.\\img\\white.jpg','.\\img\\n3.jpg','.\\img\\white.jpg'], ['.\\img\\n4.jpg','.\\img\\white.jpg','.\\img\\n5.jpg'] ], target:'.\\longImg' }; //自定义矩阵拼接图片 ImgConcatClass.conCatByMaxit(p).then(res=>{ console.log(`拼接完成,图片路径为${res}`); });
上面是“介绍一个nodejs实现图片拼接插件”的全面内容,想了解更多关于 nodejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2276.html
workflows工作流
一个极其美丽细致的女孩ComfyUI工作流
森林里有一个皮肤像抛光黑曜石的生物
一个熙熙攘攘的市场场景,里面摆满了南瓜
骨骼般的恶魔修女ComfyUI工作流
一个戴着破旧莎帽子的机械忍者站在冰林中
一个可爱的人形小机器人和一只蜗牛在森林
一个孤独的身影在未来主义城市
汉堡里的一只毛茸茸的小猫ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!