![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
svg2png-wasm
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.6.0"></script>
<!-- Or, latest -->
<script src="https://unpkg.com/svg2png-wasm"></script>
// @deno-types="https://unpkg.com/svg2png-wasm@0.6.0/index.d.ts";
export {
createSvg2png,
initialize,
svg2png,
} from 'https://unpkg.com/svg2png-wasm@0.6.0';
import { svg2png, initialize } from 'svg2png-wasm';
// const { svg2png, initialize } = require('svg2png-wasm');
import { readFileSync, writeFileSync } from 'fs';
await initialize(
readFileSync('./node_modules/svg2png-wasm/svg2png_wasm_bg.wasm'),
);
/** @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);
import { createSvg2png } from 'svg2png-wasm/core';
const font = await fetch('./Roboto.ttf').then((res) => res.arrayBuffer());
const svg2png = createSvg2png({
fonts: [
// optional
new Uint8Array(font), // require, If you use text in svg
],
});
/** @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
},
);
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"></script>
<script>
const font = await fetch('./Roboto.ttf').then((res) => res.arrayBuffer());
/** @type {Uint8Array} */
const png = await svg2pngWasm.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 InitInput =
| RequestInfo
| URL
| Response
| BufferSource
| WebAssembly.Module;
export type DefaultFontFamily = {
serifFamily?: string;
sansSerifFamily?: string;
cursiveFamily?: string;
fantasyFamily?: string;
monospaceFamily?: string;
};
export type ConverterOptions = {
fonts?: Uint8Array[];
defaultFontFamily?: DefaultFontFamily;
};
export type ConvertOptions = {
scale?: number;
width?: number;
height?: number;
};
export type Svg2png = ((
svg: string,
options?: ConvertOptions,
) => Promise<Uint8Array>) & {
dispose: () => void;
};
/**
* Initialize WASM module
* @param mod WebAssembly Module or WASM url
*/
export const initialize: (mod: Promise<InitInput> | InitInput) => Promise<void>;
/**
* @param opts Converter options (e.g. font settings)
* @returns svg2png converter
*/
export const createSvg2png: (opts?: ConverterOptions | undefined) => Svg2png;
export const svg2png: (
svg: string,
opts?: (ConverterOptions & 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.