fix: resolve PHP deprecation of imagedestroy

> Prior to PHP 8.0.0, imagedestroy() freed any memory associated with the image resource.
> As of 8.0.0, the GD extension uses objects instead of resources, and objects cannot be explicitly closed.

With PHP 8.5 this is deprecated and causes a deprecation warning!

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2026-06-11 00:59:15 +02:00
parent 2b7415ef4d
commit 2a5fc73ca9
No known key found for this signature in database
GPG key ID: 7E849AE05218500F
2 changed files with 0 additions and 9 deletions

View file

@ -265,12 +265,7 @@ class ImageManager {
}
}
$tmpFile = $newTmpFile;
imagedestroy($outputImage);
} catch (\Exception $e) {
if (isset($outputImage) && is_resource($outputImage) || $outputImage instanceof \GdImage) {
imagedestroy($outputImage);
}
$this->logger->debug($e->getMessage());
}
}

View file

@ -508,7 +508,6 @@ class Image implements IImage {
if ($res) {
if (imagealphablending($res, true)) {
if (imagesavealpha($res, true)) {
imagedestroy($this->resource);
$this->resource = $res;
return true;
} else {
@ -926,7 +925,6 @@ class Image implements IImage {
$res = imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);
if ($res === false) {
$this->logger->debug(__METHOD__ . '(): Error re-sampling process image', ['app' => 'core']);
imagedestroy($process);
return false;
}
return $process;
@ -988,7 +986,6 @@ class Image implements IImage {
$this->logger->debug('Image->centerCrop, Error re-sampling process image ' . $width . 'x' . $height, ['app' => 'core']);
return false;
}
imagedestroy($this->resource);
$this->resource = $process;
return true;
}
@ -1009,7 +1006,6 @@ class Image implements IImage {
return false;
}
$result = $this->cropNew($x, $y, $w, $h);
imagedestroy($this->resource);
$this->resource = $result;
return $this->valid();
}