https://github.com/commanderredyt/simple-identicon
A small simple identicon generator
https://github.com/commanderredyt/simple-identicon
Last synced: about 1 year ago
JSON representation
A small simple identicon generator
- Host: GitHub
- URL: https://github.com/commanderredyt/simple-identicon
- Owner: CommanderRedYT
- License: mit
- Created: 2024-12-17T09:19:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-24T23:34:23.000Z (about 1 year ago)
- Last Synced: 2025-03-25T07:51:07.617Z (about 1 year ago)
- Language: TypeScript
- Size: 934 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-identicon
## Dependencies
- [canvas](https://www.npmjs.com/package/canvas) - A Cairo-backed Canvas implementation for Node.js.
### Notes on `canvas`
For canvas to work, please check the [installation guide](https://www.npmjs.com/package/canvas#compiling) for your platform.
## Installation
```bash
npm install simple-identicon
# or
yarn add simple-identicon
```
```javascript
const { generateIdenticon } = require('simple-identicon');
const myValue = 'my-value'; // Can be a username for example
const buffer = generateIdenticon(myValue);
// Use the buffer
```
There are also some helpers for most common use cases:
```javascript
const { saveIdenticon, generateIdenticonDataUrl } = require('simple-identicon');
const myValue = 'my-value'; // Can be a username for example
// Save the identicon to a file
saveIdenticon(myValue, 'my-identicon.png');
// Or data URL
const dataUrl = generateIdenticonDataUrl(myValue);
// Use the data URL on the browser
const img = document.createElement('img');
img.src = dataUrl;
document.body.appendChild(img);
```