diff --git a/src/Captcha.php b/src/Captcha.php index 737b9437..7db426c4 100644 --- a/src/Captcha.php +++ b/src/Captcha.php @@ -237,7 +237,8 @@ class Captcha // 输出图像 imagepng($this->im); $content = ob_get_clean(); - imagedestroy($this->im); + // PHP 8.0+ frees GD images automatically; imagedestroy() is deprecated + // in PHP 8.5 and therefore must not be called by the request handler. // API调用模式 if ($this->api) { @@ -349,6 +350,6 @@ class Captcha [$width, $height] = @getimagesize($gb); // Resample $bgImage = @imagecreatefromjpeg($gb); @imagecopyresampled($this->im, $bgImage, 0, 0, 0, 0, $this->imageW, $this->imageH, $width, $height); - @imagedestroy($bgImage); + // GD images are automatically released by PHP 8.0+. } }