Package Exports
- captcha-canvas
- captcha-canvas/js-script/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (captcha-canvas) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
captcha-canvas
This is an npm package captcha-canvas helps you to make custom captcha of all types. The package uses skia-canvas to create captcha imagas. See installation section to know how to install.
Install skia-canvas before captcha-canvas installation. As skia-canvas is the peer dependencies.
Captcha Image:
Features
- Easy to use.
- Highly customisable you can customise every single value use to make this package.
- ChatGPT fails to read this captcha image and throw Error.
- Use class constructor method so you can generate as many frames as many you want by using same values.
- No bundled dependencies. You need to install them to use the package.
- Support of background images is also possible.
- Captcha adapt all the external options very easily.
How to use?
const fs = require('fs');
const { createCanvas } = require('canvas');
const { createCaptcha } = require('captcha-canvas');
const canvas = createCanvas(300, 100);
const ctx = canvas.getContext('2d');
const { text } = createCaptcha({ ctx });
console.log(text);
fs.writeFileSync('./examples/example.png', canvas.toBuffer('image/png'));You can also customize captcha as much as you want by customizing the placement of layers.
Captcha creation have mainly 3 steps draw trace line, draw decoy text and then draw captcha. If you want you can order them however you want by using Captcha class.
const fs = require('fs');
const { createCanvas } = require('canvas');
const { Captcha } = require('captcha-canvas');
const canvas = createCanvas(300, 100);
const ctx = canvas.getContext('2d');
const captcha = new Captcha({ ctx, characters: 8 });
captcha.drawCaptcha({
color: 'deeppink', // optional
size: 60, // optional
});
captcha.drawTrace({
size: 5, // optional
color: 'deeppink', // optional
});
captcha.addDecoy({
total: 100, // optional
});
const text = captcha.text;
fs.writeFileSync(`./examples/tmp/${new Date().getTime()}-${text}.png`, canvas.toBuffer('image/png'));There are many more customization you can do in this module. Check documentation for more details.
Need Help:
Open an issue if you need help regarding this module or want to report any bug.
Wanna support developer?
Star the github repo of the project. More stars motivate me to work on this project.
Open an issue to recommend some new features or report bug regarding this module.
For now, you don't have anyway to fund this project but maybe in future I update this.
Supported versions
We always recommend you to use the most latest version for more methods and better performance.
If you are at v1.x.y and I launched a new version 2.0.0 do not update it. Because it is major change which may (basically always) break your present code or the output is not as expected.
If you are at same major change version but a new patch/minor changed version is available install without any fear. Usually minor change comes with some new methods, and patch release comes with bug fixes/updated readme.
Contributors ✨
Thanks goes to these wonderful people (emoji key):
Shashank 📆 |
TheDeadCraftPT 🐛 |
IchiiDev 🐛 |
Ikramullah 📖 💻 |
ryanhex53 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
