{"record":{"id":"2aa969301be022ff","repo":"yiisoft/yii2","slug":"defined-library-imagelibrary-is-not-supported","errorCode":null,"errorMessage":"Defined library '{$imageLibrary}' is not supported","messagePattern":"Defined library '(.+?)' is not supported","errorType":"exception","errorClass":"yii\\base\\InvalidConfigException","httpStatus":null,"severity":"error","filePath":"framework/captcha/CaptchaAction.php","lineNumber":266,"sourceCode":"     * Renders the CAPTCHA image.\n     * @param string $code the verification code\n     * @return string image contents\n     * @throws InvalidConfigException if imageLibrary is not supported\n     */\n    protected function renderImage($code)\n    {\n        if (isset($this->imageLibrary)) {\n            $imageLibrary = $this->imageLibrary;\n        } else {\n            $imageLibrary = Captcha::checkRequirements();\n        }\n        if ($imageLibrary === 'gd') {\n            return $this->renderImageByGD($code);\n        } elseif ($imageLibrary === 'imagick') {\n            return $this->renderImageByImagick($code);\n        }\n\n        throw new InvalidConfigException(\"Defined library '{$imageLibrary}' is not supported\");\n    }\n\n    /**\n     * Renders the CAPTCHA image based on the code using GD library.\n     * @param string $code the verification code\n     * @return string image contents in PNG format.\n     */\n    protected function renderImageByGD($code)\n    {\n        $image = imagecreatetruecolor($this->width, $this->height);\n\n        $backColor = imagecolorallocate(\n            $image,\n            (int) ($this->backColor % 0x1000000 / 0x10000),\n            (int) ($this->backColor % 0x10000 / 0x100),\n            $this->backColor % 0x100\n        );\n        imagefilledrectangle($image, 0, 0, $this->width - 1, $this->height - 1, $backColor);","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/captcha/CaptchaAction.php#L248-L284","documentation":"Error \"Defined library '{$imageLibrary}' is not supported\" thrown in yiisoft/yii2.","triggerScenarios":"Thrown at framework/captcha/CaptchaAction.php:266 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}