https://github.com/aj3sh/node-png-captcha
A simple node library for generating PNG captcha images.
https://github.com/aj3sh/node-png-captcha
captcha captcha-image javascript node node-captcha png-captcha png-image typescript
Last synced: 8 months ago
JSON representation
A simple node library for generating PNG captcha images.
- Host: GitHub
- URL: https://github.com/aj3sh/node-png-captcha
- Owner: aj3sh
- License: gpl-3.0
- Created: 2024-05-16T14:17:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-16T15:29:42.000Z (over 1 year ago)
- Last Synced: 2024-05-16T16:29:59.299Z (over 1 year ago)
- Topics: captcha, captcha-image, javascript, node, node-captcha, png-captcha, png-image, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/png-captcha
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# png-captcha
A simple node library for generating PNG captcha images.
## Installation
To install the png-captcha, you can use npm:
```bash
npm install png-captcha
```
## Usage
```js
import fs from 'fs'
import pngCaptcha from 'png-captcha'
const options = {
size: 6, // Number of characters in the captcha text
noise: 2, // Level of noise in the captcha image
// Add more options as needed
}
const captcha = pngCaptcha.create(options)
// Captcha properties
console.log('Captcha Text:', captcha.text)
console.log('Captcha Width:', captcha.width)
console.log('Captcha Height:', captcha.height)
// Use as base64 image URL
const base64imageURL = `data:image/png;base64,${captcha.image.toString('base64')}`
// Save captcha to a PNG file
fs.writeFileSync('captcha.png', captcha.image)
```
### Options
- `size`: Number of characters in the captcha text.
- `noise`: Number of noise lines in the captcha image.
- `background`: Background color the image.
- `color`: `true` to enable color in the image.
- `width`: Width of the image.
- `height`: Height of the image.
- `fontSize`: Text size of captcha text.
## Acknowledgements
This project uses [svg-captcha](https://www.npmjs.com/package/svg-captcha) and [@resvg/resvg-js](https://www.npmjs.com/package/@resvg/resvg-js) libraries.