Module: wakabtcha/lib/image-generator

Module for rendering string into GIF image
Source:
See:

Methods

(inner) drawString(str, captchaHeightopt, captchaScribbleopt, captchaScalingopt, captchaRotationopt, captchaSpacingopt, fontopt, fontHeightopt) → {Array.<Array.<Number>>}

Render text into 2-dimensional array of pixels
Parameters:
Name Type Attributes Default Description
str String Text to draw
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
Source:
Returns:
pixels Source image as 2-dimensional array of pixels
Type
Array.<Array.<Number>>

(inner) generateGif(pixels, foregroundColoropt, backgroundColoropt, backgroundTransparentopt) → {Buffer}

Create gif file from 2-dimensional array of pixels
Parameters:
Name Type Attributes Default Description
pixels Array.<Array.<Number>> Source image as 2-dimensional array of pixels
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:
Returns:
Image (image/gif)
Type
Buffer

Type Definitions

TransformationObject

Type:
  • Object
Properties:
Name Type Description
dx Number X offset
dy Number Y offset
scale Number Scale
rotation Number Rotation angle
Source: