captchapng2

1.0.3 • Public • Published

Lite PNG captcha generator

More faster and colorful version of captchapng. (2~3 faster than orginal)

Installation

npm install captchapng2

Examples

const http = require('http');
const captchapng = require('captchapng2');
 
http.createServer(function (req, res) {
  if(req.url == '/captcha.png') {
    let rand = parseInt(Math.random() * 9000 + 1000);
    let png = new captchapng(80, 30, rand); // width,height, numeric captcha
 
    res.writeHead(200, { 'Content-Type': 'image/png'});
    res.end(png.getBuffer());
  } else {
    res.end('');
  }
}).listen(8181);
 
console.log('Web server started.\nSee http:\\\\127.0.0.1:8181\\captcha.png');

output:

captcha

Readme

Keywords

Package Sidebar

Install

npm i captchapng2

Weekly Downloads

43

Version

1.0.3

License

BSD-2-Clause

Last publish

Collaborators

  • lellansin