npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hahoo-captcha

v1.0.0

Published

a nodejs captcha module based on gm and creating random pleasing colors with PleaseJS

Downloads

10

Readme

hahoo-captcha

A nodejs captcha module based on gm and creating random pleasing colors with PleaseJS

image image

Install

First download and install GraphicsMagick or ImageMagick. In Mac OS X, you can simply use Homebrew and do:

brew install graphicsmagick
brew install imagemagick

then use npm:

npm install hahoo-captcha --save

Usage

save(filePath, options)

save a captcha image

import captcha from 'hahoo-captcha';

captcha.save('./captcha.png', {
  text: 'test',
  baseColor: 'skyblue'
})
.then((code) => {
  console.log(code);
})
.catch((err) => {
  console.log(err);
});

toBuffer(type, options)

return captcha image buffer

  • type image type (default: png)
import http from 'http';
import captcha from 'hahoo-captcha';

http.createServer((req, res) => {
  captcha.toBuffer()
  .then((data) => {
    console.log(data.text);
    res.writeHead(200, { 'Content-Type': 'image/png' });
    res.write(data.buffer);
    res.end();
  })
  .catch((err) => {
    console.log(err);
  });
}).listen(8080);

Options

  • width image width (default: 86)
  • height image height (default: 38)
  • background image background (default: #fff)
  • text captcha text (default: random a string)
  • length if text is empty, will random a string automatically, this length is the length of random string. (default: 4)
  • textX left margin of text (default: 2)
  • textY top margin of text (default: 31)
  • baseColor the name of an HTML color(e.g. 'pink') will create a random color within the HSV range of the chosen color. if null will automatically generate a random color for captcha text.
  • font font path
  • fontSize font size (default: 32)
  • wordWidth text word width (default: 19)
  • maxSwirl the max degree of swirl (default: 20)
  • lineCount the count of random line (default: 5)
  • lineWidth the width of random line (default: 1)
  • dotCount the count of random dot (default: 200)

This is use baseColor: 'skyblue' option (Please refer to HTML color):

image

License

MIT