wasm-vips libvips webassembly 实现
wasm-vips 是利用了emscripten将libvips 编译为webassembly 可以实现在node 以及浏览器中使用libvips 强大的图片处理处理
以下是一个简单的试用
参考试用
- app.js
const Vips = require('wasm-vips');
async function init() {
const vips = await Vips();
vips.Image.newFromFile('test.png')
.smartcrop(320, 320,{
interesting: vips.Interesting.attention
}).writeToFile('test2.png');
const thumbnail = vips.Image.thumbnail('test.png', 320, {
height: 320,
no_rotate: true,
crop: vips.Interesting.attention // 'attention'
});
thumbnail.writeToFile('test3.png');
}
init();
效果
原始图
生成图片
说明
以上是一个简单的使用,实际上也有基于node 的包装sharp 是一个很不错的选择,但是基于webwaasmbly 也是一个不错的选择,至少不需要对于
libvips 的依赖了,sharp 是使用的预编译好的依赖
参考资料
https://github.com/kleisauke/wasm-vips
https://www.libvips.org/
https://github.com/libvips/libvips
https://emscripten.org/
https://github.com/lovell/sharp
https://github.com/emscripten-core/emscripten
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2020-11-05 golang httpcache 一个方便的http cache 处理包
2020-11-05 httpcache4j 一个不错的httpcache 处理包
2019-11-05 go.rice 强大灵活的golang 静态资源嵌入包
2019-11-05 几个golang 静态资源嵌入包
2018-11-05 ballerina 学习二十九 数据库操作
2018-11-05 ballerina 学习二十八 快速grpc 服务开发
2018-11-05 ballerina 学习二十七 项目k8s部署&& 运行