Pre
- this project is still on working , its functionalities are not finally completed.
- it now just support number captcha and has many limitations.
installation
- install
Graphics Magick
and make sure it can work on your computer. - npm i node-gm-captcha
usage
let Captcha = require('node-gm-captcha');
Captcha.genPic({type:'num',filename:'./uniqueid.jpg'},(err,data)=>{
if(err) throw err;
console.log(data);
})
As the example above , you will get an image named 'uniqueid.jpg' under your project folder. And the data will include some data you need , such as the number , filepath , with these , you can do your business logic.
doc
genPic(param:object , callback:fn):void
-
param
key type required desc type string yes it now only can set to 'num' filename string yes where to store the pic , it should be relative path fontSize number no the font size w number no the width of the picture h number no the height of the picture -
callback:
function(err , data:metaData){ }
Todo
- make the pic more complex from recognizing
- support char type capthcha
- support mix type(char and number) captcha
- add delete method so you can easily delete the pic
- expose more customized params and method