-
Notifications
You must be signed in to change notification settings - Fork 57
/
index.d.ts
executable file
·98 lines (90 loc) · 2.66 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/// <reference types="node" />
export type ResvgRenderOptions = {
font?: {
loadSystemFonts?: boolean // Default: true, if set to false, it will be faster.
fontFiles?: string[] // A list of local font file paths to load.
fontDirs?: string[] // A list of local font directories to load.
defaultFontSize?: number // Default: 12
defaultFontFamily?: string // Default: "", if `loadSystemFonts` is enabled, it will be set to the first font in the list of system fonts.
serifFamily?: string
sansSerifFamily?: string
cursiveFamily?: string
fantasyFamily?: string
monospaceFamily?: string
}
dpi?: number
languages?: string[]
shapeRendering?:
| 0 // optimizeSpeed
| 1 // crispEdges
| 2 // geometricPrecision
textRendering?:
| 0 // optimizeSpeed
| 1 // optimizeLegibility
| 2 // geometricPrecision'
imageRendering?:
| 0 // optimizeQuality
| 1 // optimizeSpeed
fitTo?:
| { mode: 'original' }
| { mode: 'width'; value: number }
| { mode: 'height'; value: number }
| { mode: 'zoom'; value: number }
background?: string // Support CSS3 color, e.g. rgba(255, 255, 255, .8)
crop?: {
left: number
top: number
right?: number
bottom?: number
}
logLevel?: 'off' | 'error' | 'warn' | 'info' | 'debug' | 'trace'
}
export class BBox {
x: number
y: number
width: number
height: number
}
export function renderAsync(
svg: string | Buffer,
options?: ResvgRenderOptions | null,
signal?: AbortSignal | null,
): Promise<RenderedImage>
export class Resvg {
constructor(svg: Buffer | string, options?: ResvgRenderOptions | null)
toString(): string
render(): RenderedImage
/**
* Calculate a maximum bounding box of all visible elements in this SVG.
*
* Note: path bounding box are approx values.
*/
innerBBox(): BBox | undefined
/**
* Calculate a maximum bounding box of all visible elements in this SVG.
* This will first apply transform.
* Similar to `SVGGraphicsElement.getBBox()` DOM API.
*/
getBBox(): BBox | undefined
/**
* Use a given `BBox` to crop the svg. Currently this method simply changes
* the viewbox/size of the svg and do not move the elements for simplicity
*/
cropByBBox(bbox: BBox): void
imagesToResolve(): Array<string>
resolveImage(href: string, buffer: Buffer): void
/** Get the SVG width */
get width(): number
/** Get the SVG height */
get height(): number
}
export class RenderedImage {
/** Write the image data to Buffer */
asPng(): Buffer
/** Get the RGBA pixels of the image */
get pixels(): Buffer
/** Get the PNG width */
get width(): number
/** Get the PNG height */
get height(): number
}