convertSvgToPng 函数用于将 SVG 字符串转换为 PNG 格式的 Blob 对象。
import { convertSvgToPng } from '@movk/core'
const svgString = '<svg width="100" height="100"><circle cx="50" cy="50" r="40" fill="red"/></svg>'
try {
const pngBlob = await convertSvgToPng(svgString)
const url = URL.createObjectURL(pngBlob)
// 用于下载或显示
const img = document.createElement('img')
img.src = url
document.body.appendChild(img)
}
catch (error) {
console.error('SVG 转换失败:', error)
}
convertSvgToPng(svg)将 SVG 字符串转换为 PNG 格式的 Blob 对象。
b6146 — refactor: 统一源码文件命名为 camelCase