介绍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工作流
一只白色的孔雀ComfyUI工作流
一只巨大的古代乌龟后面建有一座城市的超现实场景
一位老人安详地坐在云层中钓鱼
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

jquery做一个漂亮挂墙动态时钟
html5如何3D立方体旋转特效
HTML5 Canvas 刻度尺
jquery鼠标滑过图片边框特效(jquery.focus-follow插件)
一起去看流星雨(代码)
纯CSS饼图效果
利用CSS3做一个星级评分样式
会议人员60s签到倒计时插件











