Module: wakabtcha

Wakaba captcha generator
Source:

Methods

(static) generateAnswer(startopt, grammaropt) → {String}

Generate random string
Parameters:
Name Type Attributes Default Description
start String <optional>
'%W%' Starting template
grammar Object.<String, Array.<String>> <optional>
DEFAULT_GRAMMAR Grammar object
Source:
See:
Returns:
Random string
Type
String

(static) generateImage(str, optionsopt) → {Buffer}

Generate an image with text from string
Parameters:
Name Type Attributes Description
str String Captcha answer
options Object <optional>
Override defaults
Properties
Name Type Attributes Default Description
captchaHeight Number <optional>
18 Height of image
captchaScribble Number <optional>
0.2 Random scatter level
captchaScaling Number <optional>
0.15 Amplitude of random scale change
captchaRotation Number <optional>
0.3 Amplitude of random rotation
captchaSpacing Number <optional>
2.5 Distance between letters
font Object.<String, (Number|Array.<Number>)> <optional>
DEFAULT_FONT Captcha font object, where keys are characters, values are arrays where first value is character width, other values are strokes where each stroke is represented by array of coordinates [x1,y1, x2,y2, x3,y3, ..., xN,yN]
fontHeight Number <optional>
8 Height of characters in font
foregroundColor Number <optional>
0x000000 Color of text represented by 24-bit integer (in 0xRRGGBB format)
backgroundColor Number <optional>
0xFFFFFF Color of background represented by 24-bit integer (in 0xRRGGBB format)
backgroundTransparent Boolean <optional>
true Use transparent background instead of solid color
Source:
See:
  • module:wakabtcha/image-generator~DEFAULT_FONT
Returns:
Image (image/gif)
Type
Buffer