![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
svg2png-wasm
Advanced tools
SVG to PNG converter JS library made with WASM + resvg.
See resvg for SVG support status.
npm install svg2png-wasm
# yarn add svg2png-wasm
# pnpm add svg2png-wasm
Or, using a script tag in the browser and load from unpkg.
<script src="https://unpkg.com/svg2png-wasm@0.4.0/unpkg/index.js"></script>
<!-- Or, latest -->
<script src="https://unpkg.com/svg2png-wasm"></script>
import { svg2png } from 'svg2png-wasm';
// const { svg2png } = require('svg2png-wasm');
import { readFileSync, writeFileSync } from 'fs';
/** @type {Uint8Array} */
const png = await svg2png(
'<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"> ... </svg>',
{
scale: 2, // optional
width: 400, // optional
height: 400, // optional
fonts: [
// optional
readFileSync('./Roboto.ttf'), // require, If you use text in svg
],
defaultFontFamily: {
// optional
sansSerif: 'Roboto',
},
},
);
writeFileSync('./output.png', png);
You should create svg2png
with the svg2png-wasm/core
module by specifying your own WASM.
(You can download the WASM from Releases page and deploy to your custom assets directory!)
e.g.
import { createSvg2png } from 'svg2png-wasm/core';
const svg2png = createSvg2png(
'https://unpkg.com/svg2png-wasm/svg2png_wasm_bg.wasm',
);
const font = await fetch('./Roboto.ttf').then((res) => res.arrayBuffer());
/** @type {Uint8Array} */
const png = await svg2png(
'<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"> ... </svg>',
{
scale: 2, // optional
width: 400, // optional
height: 400, // optional
fonts: [
// optional
new Uint8Array(font), // require, If you use text in svg
],
},
);
document.getElementById('output').src = URL.createObjectURL(
new Blob([png.buffer], { type: 'image/png' }),
);
Or, using a script tag in the browser and load from unpkg.
<script src="https://unpkg.com/svg2png-wasm@0.4.0/unpkg/index.js"></script>
<script>
const font = await fetch('./Roboto.ttf').then((res) => res.arrayBuffer());
/** @type {Uint8Array} */
const png = await SVG2PNG.svg2png(
'<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"> ... </svg>',
{
scale: 2, // optional
width: 400, // optional
height: 400, // optional
fonts: [
// optional
new Uint8Array(font), // require, If you use text in svg
],
},
);
document.getElementById('output').src = URL.createObjectURL(
new Blob([png.buffer], { type: 'image/png' }),
);
</script>
svg2png-wasm
moduleexport type DefaultFontFamily = {
serifFamily?: string;
sansSerifFamily?: string;
cursiveFamily?: string;
fantasyFamily?: string;
monospaceFamily?: string;
};
export type ConvertOptions = {
scale?: number;
width?: number;
height?: number;
fonts?: Uint8Array[];
defaultFontFamily?: DefaultFontFamily;
};
export const svg2png: (
svg: string,
opts?: ConvertOptions | undefined,
) => Promise<Uint8Array>;
svg2png-wasm/core
moduleexport const createSvg2png = (
mod: Promise<WebAssembly.Module | Response | Request | URL | string> | WebAssembly.Module | Response | Request | URL | string
) => (
svg: string,
opts?: ConvertOptions | undefined,
) => Promise<Uint8Array>;
MPL-2.0 License
WELCOME!
FAQs
A svg to png converter made with wasm.
The npm package svg2png-wasm receives a total of 11,522 weekly downloads. As such, svg2png-wasm popularity was classified as popular.
We found that svg2png-wasm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.