0.0.1 • Published 11 months ago

koishi-plugin-resvg v0.0.1

Weekly downloads
-
License
AGPL-3.0
Repository
github
Last release
11 months ago

koishi-plugin-resvg

npm

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 12Node.js 14Node.js 16Node.js 18Node.js 20npm
Windows x64npm version
Windows x32npm version
Windows arm64npm version
macOS x64npm version
macOS arm64(M1)npm version
Linux x64 gnunpm version
Linux x64 muslnpm version
Linux arm gnunpm version
Linux arm64 gnunpm version
Linux arm64 muslnpm version
Android arm64npm version
Android armv7npm version