ctx.puppeteer.render能不能调整渲染出的图片质量和格式呀

默认出的png都好大,能不能出jpg,或者压缩一下画质也行

2 个赞

Not currently, you could transform it in the runtime yourself since there are tons of libraries converting image formats.

1 个赞

Could you name some for me? I’m a complete beginner and don’t know which one I can use.

1 个赞

There are really tons of them, you can just search for keywords in npmjs, the first coming to my brain is jpeg-js, which is really nice:

Note: although it recommends sharp and sharp is really good but unfortunately it is a nodejs add-on thus difficultly to be handled in Koishi.

1 个赞

如果可以,实际上我已经做了一个接口。它会自动压缩图片。返回的图片也就几十k了。

如果你需要,我把这个后端接口的文件发一下,自己部署

1 个赞

好呀,我试试看

1 个赞

效果图

image

https://b2.smmmax.top/htmlApi.zip

还在上班,具体配置可以自行看代码

安装依赖
npm install

运行后端服务器
node app.js

访问接口地址

4 个赞

好棒好棒好棒

1 个赞