koishi-plugin-resvg
v0.0.1
Published
[A high-performance SVG renderer service](https://github.com/yisibl/resvg-js) 高性能 svg 渲染服务
Downloads
156
Maintainers
Readme
koishi-plugin-resvg
resvg service
example
import { Context } from 'koishi'
import { exit } from 'process'
import Resvg from 'koishi-plugin-resvg'
import { resolve } from 'path';
import { writeFileSync } from 'fs';
const app = new Context()
app.plugin(Resvg);
(async () => {
await app.start()
const svg = await app.resvg.renderAsync(`<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<rect x="10" y="10" width="80" height="80" fill="orange" />
</svg>`)
writeFileSync(resolve(__dirname, '0.jpg'), svg.asPng())
const resvg = app.resvg.newResvg(`<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<rect x="10" y="10" width="80" height="80" fill="orange" />
</svg>`)
let svg2 = resvg.render()
writeFileSync(resolve(__dirname, '1.jpg'), svg2.asPng())
console.log(resvg.width, resvg.height)
exit()
})()
Support matrix
| | Node.js 12 | Node.js 14 | Node.js 16 | Node.js 18 | Node.js 20 | npm | | ---------------- | ---------- | ---------- | ---------- | ---------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Windows x64 | ✓ | ✓ | ✓ | ✓ | ✓ | | | Windows x32 | ✓ | ✓ | ✓ | ✓ | ✓ | | | Windows arm64 | ✓ | ✓ | ✓ | ✓ | ✓ | | | macOS x64 | ✓ | ✓ | ✓ | ✓ | ✓ | | | macOS arm64(M1) | ✓ | ✓ | ✓ | ✓ | ✓ | | | Linux x64 gnu | ✓ | ✓ | ✓ | ✓ | ✓ | | | Linux x64 musl | ✓ | ✓ | ✓ | ✓ | ✓ | | | Linux arm gnu | ✓ | ✓ | ✓ | ✓ | ✓ | | | Linux arm64 gnu | ✓ | ✓ | ✓ | ✓ | ✓ | | | Linux arm64 musl | ✓ | ✓ | ✓ | ✓ | ✓ | | | Android arm64 | ✓ | ✓ | ✓ | ✓ | ✓ | | | Android armv7 | ✓ | ✓ | ✓ | ✓ | ✓ | |