Closed rasteiner closed 1 year ago
Since PHP8 the GD functions work with the GdImage class and no longer with resources. The __destruct function: https://github.com/claviska/SimpleImage/blob/a447473883e5dd0daa0d014ae849f0db5b8a1d08/src/claviska/SimpleImage.php#L116-L124 however checks if the the current image is both a GdImage as well as a resource. But as far as I can test, GdImages are not resources:
GdImage
__destruct
resource
$img = imagecreatetruecolor(10,10); var_dump($img); // instance of class GdImage var_dump(is_resource($img)); // false
Run code in sandbox
Therefore the conditions are never met and the image is never destroyed.
Since PHP 7 support has been dropped, the function could be rewritten as:
protected $image = null; // snip /** * Destroys the image resource. */ public function __destruct() { if ($this->image instanceof \GdImage) { imagedestroy($this->image); } }
Good catch. This was left over from a much earlier version — perhaps PHP 5.6. Would you like to send a PR for this update?
Since PHP8 the GD functions work with the
GdImage
class and no longer with resources. The__destruct
function: https://github.com/claviska/SimpleImage/blob/a447473883e5dd0daa0d014ae849f0db5b8a1d08/src/claviska/SimpleImage.php#L116-L124 however checks if the the current image is both aGdImage
as well as aresource
. But as far as I can test, GdImages are not resources:Run code in sandbox
Therefore the conditions are never met and the image is never destroyed.
Since PHP 7 support has been dropped, the function could be rewritten as: