diff --git a/src/Svg/Document.php b/src/Svg/Document.php index 24c0681..9db2b78 100644 --- a/src/Svg/Document.php +++ b/src/Svg/Document.php @@ -161,7 +161,9 @@ function ($parser, $name) {} } xml_parse($parser, "", true); - xml_parser_free($parser); + if (PHP_MAJOR_VERSION < 8) { + xml_parser_free($parser); + } return $this->handleSizeAttributes($rootAttributes); } @@ -257,7 +259,9 @@ public function render(SurfaceInterface $surface) xml_parse($parser, "", true); - xml_parser_free($parser); + if (PHP_MAJOR_VERSION < 8) { + xml_parser_free($parser); + } } protected function svgOffset($attributes) diff --git a/src/Svg/Surface/CPdf.php b/src/Svg/Surface/CPdf.php index ce807a2..53732c4 100644 --- a/src/Svg/Surface/CPdf.php +++ b/src/Svg/Surface/CPdf.php @@ -5612,7 +5612,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte) // Cast to 8bit+palette $imgalpha_ = @imagecreatefrompng($tempfile_alpha); imagecopy($imgalpha, $imgalpha_, 0, 0, 0, 0, $wpx, $hpx); - imagedestroy($imgalpha_); + if (PHP_MAJOR_VERSION < 8) { + imagedestroy($imgalpha_); + } imagepng($imgalpha, $tempfile_alpha); // Make opaque image @@ -5658,7 +5660,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte) // Cast to 8bit+palette $imgalpha_ = @imagecreatefrompng($tempfile_alpha); imagecopy($imgalpha, $imgalpha_, 0, 0, 0, 0, $wpx, $hpx); - imagedestroy($imgalpha_); + if (PHP_MAJOR_VERSION < 8) { + imagedestroy($imgalpha_); + } imagepng($imgalpha, $tempfile_alpha); } else { $tempfile_alpha = null; @@ -5711,7 +5715,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte) // extract image without alpha channel $imgplain = imagecreatetruecolor($wpx, $hpx); imagecopy($imgplain, $img, 0, 0, 0, 0, $wpx, $hpx); - imagedestroy($img); + if (PHP_MAJOR_VERSION < 8) { + imagedestroy($img); + } imagepng($imgalpha, $tempfile_alpha); imagepng($imgplain, $tempfile_plain); @@ -5722,13 +5728,17 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte) // embed mask image if ($tempfile_alpha) { $this->addImagePng($imgalpha, $tempfile_alpha, $x, $y, $w, $h, true); - imagedestroy($imgalpha); + if (PHP_MAJOR_VERSION < 8) { + imagedestroy($imgalpha); + } $this->imageCache[] = $tempfile_alpha; } // embed image, masked with previously embedded mask $this->addImagePng($imgplain, $tempfile_plain, $x, $y, $w, $h, false, ($tempfile_alpha !== null)); - imagedestroy($imgplain); + if (PHP_MAJOR_VERSION < 8) { + imagedestroy($imgplain); + } $this->imageCache[] = $tempfile_plain; } @@ -5813,11 +5823,13 @@ function addPngFromFile($file, $x, $y, $w = 0, $h = 0) } imagecopy($img, $imgtmp, 0, 0, 0, 0, $sx, $sy); - imagedestroy($imgtmp); + if (PHP_MAJOR_VERSION < 8) { + imagedestroy($imgtmp); + } } $this->addImagePng($img, $file, $x, $y, $w, $h); - if ($img) { + if ($img && PHP_MAJOR_VERSION < 8) { imagedestroy($img); } }