Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sankooc/captcha-node
create captcha with ImageMagick
https://github.com/sankooc/captcha-node
captcha
Last synced: 26 days ago
JSON representation
create captcha with ImageMagick
- Host: GitHub
- URL: https://github.com/sankooc/captcha-node
- Owner: sankooc
- License: mit
- Created: 2016-09-19T02:30:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-30T06:38:09.000Z (about 8 years ago)
- Last Synced: 2024-10-09T10:01:48.349Z (3 months ago)
- Topics: captcha
- Language: JavaScript
- Size: 99.6 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# captcha-node
[![NPM](https://nodei.co/npm/captcha-node.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/captcha-node/)
create captcha with ImageMagick or GraphicsMagick
## demo
![demo](demo/gen.png)
## prepare
* install ImageMagick
```
brew install imagemagick
```or if you want to use GraphicsMagick
```
brew install graphicsmagick
```Installation for other systems: [ImageMagick](http://www.imagemagick.org/script/binary-releases.php), [GraphicsMagick](http://www.graphicsmagick.org/README.html)
* install package
```
npm install captcha-node
```## sample code
callback
```
var captcha = require('captcha-node')
var fs = require('fs')
var target = __dirname + '/gen.png';
captcha.genCaptcha({},function(err,data){
if(err){
console.trace(err.stack);
return
}
fs.writeFileSync(target,data.data);
});
```co
```
co(function* (){
return yield captcha.genCaptcha({})
}).then((data) => {
fs.writeFileSync(target,data.data);
}).catch(console.error.bind(console));```
## option
* **width** *(Default: 150)* - Image width.
* **height** *(Default: 50)* - Image height.
* **fontsize** *(Default: 30)* - Font size.
* **skech** *(Default: 10)* - Strokes count.
* **fontWidth** *(Default: 3)* - Width of text and stroke.
* **bgcolor** *(Default: '#fff')* - Background color.
* **scolor** *(Default: '#ddd')* - Stroke color.
* **fcolor** *(Default: '#ccc')* - Font color.
* **text** - Captcha text.
* **font_path** *(Default: '/font/comic.ttf')* - Path to the font file.
* **engine** *(Default: 'ImageMagick')* - Graphics engine tool. Set as 'GraphicsMagick' if you use it.