/** * Create captcha image * * @param string $config * @return ImageManager->response */ public function create($config = 'default') { $this->backgrounds = $this->files->files(__DIR__ . '/../assets/backgrounds'); $this->fonts = $this->files->files(__DIR__ . '/../assets/fonts'); $this->fonts = array_values($this->fonts); //reset fonts array index $this->configure($config); $this->text = $this->generate(); session_start(); $_SESSION['text'] = $this->text; $this->canvas = $this->imageManager->canvas($this->width, $this->height, $this->bgColor); if ($this->bgImage) { $this->image = $this->imageManager->make($this->background())->resize($this->width, $this->height); $this->canvas->insert($this->image); } else { $this->image = $this->canvas; } if ($this->contrast != 0) { $this->image->contrast($this->contrast); } $this->text(); $this->lines(); if ($this->sharpen) { $this->image->sharpen($this->sharpen); } if ($this->invert) { $this->image->invert($this->invert); } if ($this->blur) { $this->image->blur($this->blur); } return $this->image->response('png', $this->quality); }
/** * @param string $config * @return ImageManager->response */ public function create($config = 'default') { $this->backgrounds = $this->files->files(base_path() . "/resources/assets/Captcha/backgrounds"); $this->fonts = $this->files->files(base_path() . "/resources/assets/Captcha/fonts"); $this->configure($config); $this->text = $this->generate(); $this->canvas = $this->imageManager->canvas($this->width, $this->height, $this->bgColor); if ($this->bgImage) { $this->image = $this->imageManager->make($this->background())->resize($this->width, $this->height); $this->canvas->insert($this->image); } else { $this->image = $this->canvas; } if ($this->contrast != 0) { $this->image->contrast($this->contrast); } $this->text(); $this->lines(); if ($this->sharpen) { $this->image->sharpen($this->sharpen); } if ($this->invert) { $this->image->invert($this->invert); } if ($this->blur) { $this->image->blur($this->blur); } return $this->image->response('png', $this->quality); }