Skip to contents

Generates a custom captcha image using the magick package. We name this captcha as R-Captcha.

Usage

captcha_generate(
  write_disk = FALSE,
  path = getwd(),
  chars = c(0:9, letters, LETTERS),
  n_chars = 4,
  n_rows = 60,
  n_cols = 120,
  p_rotate = 0.8,
  p_line = 0.8,
  p_stroke = 0.3,
  p_box = 0.3,
  p_implode = 0.2,
  p_oilpaint = 0,
  p_noise = 0.4,
  p_lat = 0
)

Arguments

write_disk

write image to disk? Defaults to FALSE.

path

path to save images. Defaults to current directory.

chars

which chars to generate. Defaults upper/lower case letters and numbers

n_chars

captcha length. Defaults to 4.

n_rows, n_cols

image dimensions. Defaults to 60x120 image.

p_rotate

probability to add rotation. Defaults to 80%.

p_line

probability to add strike through line. Defaults to 80%.

p_stroke

probability to add stroke color. Defaults to 30%.

p_box

probability to add bounding box to text. Defaults to 30%.

p_implode

probability to add imploding effect. Defaults to 20%.

p_oilpaint

probability to add oil paint effect. Defaults to 0.

p_noise

probability to add random noise to image. Defaults to 40%.

p_lat

probability to add LAT algorithm to image. Defaults to 0.

Value

object of class captcha, which is a list containing three elements: image-magick object and the label.

Examples


# must have ghostscript enabled in ImageMagick
# run check_magick_ghostscript() for details.
if (magick::magick_config()$ghostscript) {
  captcha_generate()
  captcha_generate(n_chars = 5)
}