yiisoft/yii2 · error · yii\base\InvalidConfigException
Defined library '{$imageLibrary}' is not supported
Error message
Defined library '{$imageLibrary}' is not supported What it means
Error "Defined library '{$imageLibrary}' is not supported" thrown in yiisoft/yii2.
Source
Thrown at framework/captcha/CaptchaAction.php:266
* Renders the CAPTCHA image.
* @param string $code the verification code
* @return string image contents
* @throws InvalidConfigException if imageLibrary is not supported
*/
protected function renderImage($code)
{
if (isset($this->imageLibrary)) {
$imageLibrary = $this->imageLibrary;
} else {
$imageLibrary = Captcha::checkRequirements();
}
if ($imageLibrary === 'gd') {
return $this->renderImageByGD($code);
} elseif ($imageLibrary === 'imagick') {
return $this->renderImageByImagick($code);
}
throw new InvalidConfigException("Defined library '{$imageLibrary}' is not supported");
}
/**
* Renders the CAPTCHA image based on the code using GD library.
* @param string $code the verification code
* @return string image contents in PNG format.
*/
protected function renderImageByGD($code)
{
$image = imagecreatetruecolor($this->width, $this->height);
$backColor = imagecolorallocate(
$image,
(int) ($this->backColor % 0x1000000 / 0x10000),
(int) ($this->backColor % 0x10000 / 0x100),
$this->backColor % 0x100
);
imagefilledrectangle($image, 0, 0, $this->width - 1, $this->height - 1, $backColor);View on GitHub (pinned to 66f00d18a2)
When it happens
Trigger: Thrown at framework/captcha/CaptchaAction.php:266 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17).
Data as JSON: /api/errors/2aa969301be022ff.
Report an issue: GitHub.