img-svgizer
code:demo0.ts
async function demo0 () {
const buf = await fetchImage(srcUrl)
const base64img = encode(buf)
const dataUri = data:image/png;base64,${base64img}
const svgTagText = createSvg(dataUri, {
width: 43,
height: 44
})
console.log(svgTagText)
}
demo0()
code:demo1.ts
async function demo1 () {
const style = [
`.source text {
font-size: 11px;
font-weight: 400;
text-decoration: none;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}`,
`.source text:hover {
text-decoration: underline;
}`
]
const options: Options = {
width: 571,
height: 506,
className: 'svg-screenshot',
dataset: {
title: 'The_Great_Burgerに行ってきた - daiiz',
},
externals: [
{
x: 53.5, y: 79, width: 75, height: 17,
text: 'パンケーキ'
},
{
x: 76, y: 106, width: 15, height: 17,
text: '卵'
},
{
x: 121, y: 160, width: 60, height: 17,
text: '目玉焼き'
},
{
x: 31, y: 325, width: 300, height: 17
},
{
x: 4, y: 502,
text: 'The Great Burgerに行ってきた - daiiz - Scrapbox',
className: 'source'
},
{
x: 31, y: 185, width: 300, height: 300,
type: 'img'
}
],
style
}
const base64img = encode(await fetchImage(srcUrl))
const dataUri = data:image/png;base64,${base64img}
console.log(createSvg(dataUri, options))
}
demo1()