yiisoft/yii2 · error · yii\base\InvalidConfigException

Either GD PHP extension with FreeType support or ImageMagick

Error message

Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required.

What it means

Error "Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required." thrown in yiisoft/yii2.

Source

Thrown at framework/captcha/Captcha.php:175

     * This method will check the existence of ImageMagick and GD extensions.
     * @return string the name of the graphic extension, either "imagick" or "gd".
     * @throws InvalidConfigException if neither ImageMagick nor GD is installed.
     */
    public static function checkRequirements()
    {
        if (extension_loaded('imagick')) {
            $imagickFormats = (new \Imagick())->queryFormats('PNG');
            if (in_array('PNG', $imagickFormats, true)) {
                return 'imagick';
            }
        }
        if (extension_loaded('gd')) {
            $gdInfo = gd_info();
            if (!empty($gdInfo['FreeType Support'])) {
                return 'gd';
            }
        }
        throw new InvalidConfigException('Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required.');
    }
}

View on GitHub (pinned to 66f00d18a2)

When it happens

Trigger: Thrown at framework/captcha/Captcha.php:175 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/c1599427bbd205c6. Report an issue: GitHub.