From 9eb6959c3b70e1f54397cac2222a12522dd2e635 Mon Sep 17 00:00:00 2001 From: manusfreedom Date: Wed, 29 Apr 2026 15:49:41 +0200 Subject: [PATCH] Fix PHP 8.x & imagedestroy --- Adapter/GD.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Adapter/GD.php b/Adapter/GD.php index c0a1f15..7a15ed8 100644 --- a/Adapter/GD.php +++ b/Adapter/GD.php @@ -61,7 +61,9 @@ public function fillBackground($background = 0xffffff) $n = imagecreatetruecolor($w, $h); imagefill($n, 0, 0, ImageColor::gdAllocate($this->resource, $background)); imagecopyresampled($n, $this->resource, 0, 0, 0, 0, $w, $h, $w, $h); - imagedestroy($this->resource); + if (PHP_VERSION_ID < 80000) { + imagedestroy($this->resource); + } $this->resource = $n; return $this; @@ -101,7 +103,9 @@ protected function doResize($bg, int $target_width, int $target_height, int $new $height ); - imagedestroy($this->resource); + if (PHP_VERSION_ID < 80000) { + imagedestroy($this->resource); + } $this->resource = $n; @@ -117,7 +121,9 @@ public function crop($x, $y, $width, $height) imagealphablending($destination, false); imagesavealpha($destination, true); imagecopy($destination, $this->resource, 0, 0, (int) $x, (int) $y, $this->width(), $this->height()); - imagedestroy($this->resource); + if (PHP_VERSION_ID < 80000) { + imagedestroy($this->resource); + } $this->resource = $destination; return $this; @@ -268,7 +274,9 @@ public function gaussianBlur($blurFactor = 1) imagefilter($this->resource, IMG_FILTER_GAUSSIAN_BLUR); // clean up - imagedestroy($prevImage); + if (PHP_VERSION_ID < 80000) { + imagedestroy($prevImage); + } return $this; } @@ -480,7 +488,9 @@ public function flip($flipVertical, $flipHorizontal) imagesavealpha($imgdest, true); if (imagecopyresampled($imgdest, $this->resource, 0, 0, $src_x, $src_y, $width, $height, $src_width, $src_height)) { - imagedestroy($this->resource); + if (PHP_VERSION_ID < 80000) { + imagedestroy($this->resource); + } $this->resource = $imgdest; } }