MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / svgPixelSize

Function svgPixelSize

ui/src/lib/export-image.ts:32–36  ·  view source on GitHub ↗
(svg: string)

Source from the content-addressed store, hash-verified

30
31/** The SVG's own root width/height, which the raster canvas has to match. */
32export function svgPixelSize(svg: string): { width: number; height: number } {
33 const width = Number(/\bwidth="(\d+(?:\.\d+)?)"/.exec(svg)?.[1] ?? 0);
34 const height = Number(/\bheight="(\d+(?:\.\d+)?)"/.exec(svg)?.[1] ?? 0);
35 return { width: Math.max(1, Math.round(width)), height: Math.max(1, Math.round(height)) };
36}
37
38function loadImage(url: string): Promise<HTMLImageElement> {
39 return new Promise((resolve, reject) => {

Callers 1

svgToPngFunction · 0.85

Calls 2

NumberInterface · 0.85
execMethod · 0.65

Tested by

no test coverage detected