CaptchaGenerator

Description

CaptchaGenerator class

Example

const captcha = new CaptchaGenerator();
captcha.setDimension(150, 450);
captcha.setCaptcha({font: "Comic Sans", size: 60});
captcha.setDecoy({opacity: 0.5});
captcha.setTrace({color: "blue"});
const {buffer, text} = await captcha.generate();

Constructors

Properties

background?: string | Buffer
captchaSegments: SetCaptchaOptions[] = []
height: number
width: number

Accessors

  • get text(): string
  • Returns string

    The captcha text

    Method

    text

    Description

    Get the captcha text

Methods

  • Returns Promise<Buffer>

    The captcha image buffer

    Method

    generate

    Description

    Generate the captcha image

  • Parameters

    • options: {
          background?: Image;
      } = {}

      The options for generating the captcha

      • Optional background?: Image

        The background image

    Returns Buffer

    The captcha image buffer

    Method

    generateSync

    Description

    Generate the captcha image synchronously

  • Parameters

    • image: string | Buffer

      The background image

    Returns this

    The captcha generator instance

    Method

    setBackground

    Description

    Set the background of the captcha

  • Parameters

    Returns this

    The captcha generator instance

    Method

    setDecoy

    Description

    Set the decoy options

  • Parameters

    • height: number

      The height of the captcha

    • width: number

      The width of the captcha

    Returns this

    The captcha generator instance

    Method

    setDimension

    Description

    Set the dimension of the captcha

  • Parameters

    Returns this

    The captcha generator instance

    Method

    setTrace

    Description

    Set the trace options