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 🙏

© 2026 – Pkg Stats / Ryan Hefner

complexcaptcha

v0.9.4

Published

Project that aims for generating captcha image with various customization options - for Node.JS

Downloads

2

Readme


Project that aims for generating captcha image with various customization options - for Node.JS


Quick look

For simply generating and saving one captcha image:

import * as fs from "fs";

import ComplexCaptcha from "complexcaptcha";

//

// generating captcha
const data = ComplexCaptcha.Generate({
    mimeType:   "image/jpeg"
});

// saving to file
fs.writeFileSync(`./captcha__${data.solution}.jpeg`), data.buffer);

Current features

  • Custom characters list (string)
  • Custom font or fonts selected randomly for each character.
  • Custom colors by creating palette of 3 colors (background, foreground, details) or providing array of palettes (random picking)
  • Displacement of individual characters on y-axis
  • Deformation of individual characters (scaling/skewing)
  • Rotation of individual characters
  • Pairing individual characters for overlaping
  • Randomly picking characters for being impostors (characters that doesn't matter in answer/solution)
  • Randomly picking font for each character.
  • Ability to disable features for individual provided fonts
  • Ability to disable characters for individual provided fonts
  • Drawing fake captcha text in background with smaller font size (dummies)
  • Drawing dirt on top of captcha (lines, xor linex/box/islands)

How to build

To build from typescript to javascript CommonJS module, just run command npm run build. You will find built code in dist directory. This command build whole module along with examples.


Examples

To run any of the examples located in examples folder:

  1. Run command npm run build for building whole module along with examples.
  2. Run command npm run example1 for running example1 program.
  3. Look at the output in output/example1 directory.

API

Registering custom font

If You want to use custom font/s, just call ComplexCaptcha.CanvasRegisterFont function with same arguments as in registerFont function in canvas module for Node.js. Read more details here: https://github.com/Automattic/node-canvas#registerfont

ComplexCaptcha.Generate

Static function ComplexCaptcha.Generate generates captcha and returns object of GeneratedCaptcha type. It takes one argument, object of GenerateOptions type.

GeneratedCaptcha

Object of GeneratedCaptcha type contains fields:

GeneratedCaptcha.Instructions

GenerateOptions

Object of GenerateOptions type may contains fields:

GenerateOptions, Palette

GenerateOptions, FontInfo/FrontFontInfo

Object of FontInfo/FrontFontInfo type contains information about font used to render text:

GenerateOptions.CharDisplacementVOptions

Object of CharDisplacementVOptions type contains information about how generator will displace vertically characters on image.

GenerateOptions.CharRotationOptions

Object of CharRotationOptions type contains information about how generator will rotate characters on image.

GenerateOptions.CharDeformationOptions

Object of CharDeformationOptions type contains information about how generator will deformate characters on image. First, a chance test will be performed, then the deformation type will be selected randomly (scaling on x or y axis, or skewing on x or y axis)

GenerateOptions.PairingOptions

Object of PairingOptions type contains information about how generator will pair characters rendered on image. Pairing is feature that randomly pair two characters into one unit, that will be rotated/deformated together and also both characters in pair will slightly overlapped for less readability and greater challange (can be customized).

GenerateOptions.ImpostorsOptions

Object of ImpostorsOptions type contains information about fake characters will be placed among real ones. User is challanged to skip fake characters when rewriting captcha. Fake characters are marked by circle colored by palette.details, but modified to be semi-transparent.

GenerateOptions.DirtOptions

Object of DirtOptions type contains information about drawings that will be put on top of whole image to make it less readable for cpu. Currently only xor box and line are avaliable and are selected randomly.

GenerateOptions.DummiesOptions

Object of DummiesOptions type contains information about smaller text units that will be put behind real text to make whole captcha less readable for cpu.