better-captcha-image
v1.0.2
Published
Captcha image generator
Downloads
4
Maintainers
Readme
Information
Dependencies
This relies on a native module called node-canvas. You will need to install cairo, so read https://github.com/learnboost/node-canvas/wiki before installing.
Usage
var { generateCaptcha } = require('better-captcha-image');
var captcha = generateCaptcha({
code_length: 6, // Number of characters generated
width: 300, // Width of the generated image
height: 100, // Height of the generated image
padding: 10, // Padding of each segment (segment is the width divided by the code length)
font_family: "Arial", // Font of the captcha
font_size: [50,75], // Random percent of segment width between the two values
letter_rotate: [-45,45], // Random degrees between the two values
line_size: 5, // Random percent of segment width between the two values
font_color: "#00bbbb", // Hexadecimal value
line_color: "#00bbbb", // Hexadecimal value
filler_count: [10,15], // Random number between the two value
filler_font_size: [15,20], // Random font size (in pixels) between the two value
filler_letter_rotate: [-45,45], // Random degrees between the two values
filler_font_color: "#646464", // Hexadecimal value
show_copyright: true, // Display copyright text
copyright_text: "Example", // Copyright text
copyright_size: 10, // Copyright size (in pixels)
returnAsUrl: false // Return image as base64 URL instead of a Buffer
});
console.log(captcha.code, captcha.image);
LICENSE
Copyright (c) 2022 Nagynorbii. All rights reserved
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.