@dicebear/converter 10.2.0-rc.1 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,48 @@
|
|
|
1
1
|
<h1><img src="https://www.dicebear.com/logo-readme.svg" width="28" /> DiceBear Converter</h1>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<img src="https://api.dicebear.com/6.x/open-peeps/svg?seed=Kitty&backgroundColor=0096c7&radius=10" width="64" />
|
|
6
|
-
<img src="https://api.dicebear.com/6.x/pixel-art/svg?seed=Lilly&backgroundColor=00b4d8&radius=10" width="64" />
|
|
7
|
-
<img src="https://api.dicebear.com/6.x/lorelei/svg?seed=Tigger&backgroundColor=48cae4&radius=10" width="64" />
|
|
8
|
-
<img src="https://api.dicebear.com/6.x/bottts/svg?seed=Zoe&backgroundColor=90e0ef&radius=10" width="64" />
|
|
9
|
-
<img src="https://api.dicebear.com/6.x/initials/svg?seed=..&backgroundColor=ade8f4&radius=10" width="64" />
|
|
10
|
-
</p>
|
|
3
|
+
Converts DiceBear avatars (or any SVG) to raster formats: PNG, JPEG, WebP and
|
|
4
|
+
AVIF. Works in Node.js and modern browsers.
|
|
11
5
|
|
|
12
6
|
[Playground](https://www.dicebear.com/playground) |
|
|
13
7
|
[Documentation](https://www.dicebear.com/introduction)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @dicebear/converter
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires Node.js 22+ or any modern browser.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { Avatar } from '@dicebear/core';
|
|
21
|
+
import { toPng } from '@dicebear/converter';
|
|
22
|
+
|
|
23
|
+
// From a style definition (here from the @dicebear/styles package)
|
|
24
|
+
import definition from '@dicebear/styles/lorelei.json' with { type: 'json' };
|
|
25
|
+
|
|
26
|
+
const avatar = new Avatar(definition, { seed: 'John Doe' });
|
|
27
|
+
|
|
28
|
+
const png = toPng(avatar, { size: 256 });
|
|
29
|
+
|
|
30
|
+
await png.toDataUri(); // data:image/png;base64,...
|
|
31
|
+
await png.toArrayBuffer(); // ArrayBuffer
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`toJpeg`, `toWebp` and `toAvif` work the same way. Each function also accepts a
|
|
35
|
+
raw SVG string instead of an `Avatar`.
|
|
36
|
+
|
|
37
|
+
## Sponsors
|
|
38
|
+
|
|
39
|
+
Advertisement: Many thanks to our sponsors who provide us with free or
|
|
40
|
+
discounted products.
|
|
41
|
+
|
|
42
|
+
<a href="https://bunny.net/" target="_blank" rel="noopener noreferrer">
|
|
43
|
+
<picture>
|
|
44
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://www.dicebear.com/sponsors/bunny-light.svg">
|
|
45
|
+
<source media="(prefers-color-scheme: light)" srcset="https://www.dicebear.com/sponsors/bunny-dark.svg">
|
|
46
|
+
<img alt="bunny.net" src="https://www.dicebear.com/sponsors/bunny-dark.svg" height="64">
|
|
47
|
+
</picture>
|
|
48
|
+
</a>
|