@@ -5612,7 +5612,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
56125612 // Cast to 8bit+palette
56135613 $ imgalpha_ = @imagecreatefrompng ($ tempfile_alpha );
56145614 imagecopy ($ imgalpha , $ imgalpha_ , 0 , 0 , 0 , 0 , $ wpx , $ hpx );
5615- imagedestroy ($ imgalpha_ );
5615+ if (PHP_MAJOR_VERSION < 8 ) {
5616+ imagedestroy ($ imgalpha_ );
5617+ }
56165618 imagepng ($ imgalpha , $ tempfile_alpha );
56175619
56185620 // Make opaque image
@@ -5658,7 +5660,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
56585660 // Cast to 8bit+palette
56595661 $ imgalpha_ = @imagecreatefrompng ($ tempfile_alpha );
56605662 imagecopy ($ imgalpha , $ imgalpha_ , 0 , 0 , 0 , 0 , $ wpx , $ hpx );
5661- imagedestroy ($ imgalpha_ );
5663+ if (PHP_MAJOR_VERSION < 8 ) {
5664+ imagedestroy ($ imgalpha_ );
5665+ }
56625666 imagepng ($ imgalpha , $ tempfile_alpha );
56635667 } else {
56645668 $ tempfile_alpha = null ;
@@ -5711,7 +5715,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
57115715 // extract image without alpha channel
57125716 $ imgplain = imagecreatetruecolor ($ wpx , $ hpx );
57135717 imagecopy ($ imgplain , $ img , 0 , 0 , 0 , 0 , $ wpx , $ hpx );
5714- imagedestroy ($ img );
5718+ if (PHP_MAJOR_VERSION < 8 ) {
5719+ imagedestroy ($ img );
5720+ }
57155721
57165722 imagepng ($ imgalpha , $ tempfile_alpha );
57175723 imagepng ($ imgplain , $ tempfile_plain );
@@ -5722,13 +5728,17 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
57225728 // embed mask image
57235729 if ($ tempfile_alpha ) {
57245730 $ this ->addImagePng ($ imgalpha , $ tempfile_alpha , $ x , $ y , $ w , $ h , true );
5725- imagedestroy ($ imgalpha );
5731+ if (PHP_MAJOR_VERSION < 8 ) {
5732+ imagedestroy ($ imgalpha );
5733+ }
57265734 $ this ->imageCache [] = $ tempfile_alpha ;
57275735 }
57285736
57295737 // embed image, masked with previously embedded mask
57305738 $ this ->addImagePng ($ imgplain , $ tempfile_plain , $ x , $ y , $ w , $ h , false , ($ tempfile_alpha !== null ));
5731- imagedestroy ($ imgplain );
5739+ if (PHP_MAJOR_VERSION < 8 ) {
5740+ imagedestroy ($ imgplain );
5741+ }
57325742 $ this ->imageCache [] = $ tempfile_plain ;
57335743 }
57345744
@@ -5813,11 +5823,13 @@ function addPngFromFile($file, $x, $y, $w = 0, $h = 0)
58135823 }
58145824
58155825 imagecopy ($ img , $ imgtmp , 0 , 0 , 0 , 0 , $ sx , $ sy );
5816- imagedestroy ($ imgtmp );
5826+ if (PHP_MAJOR_VERSION < 8 ) {
5827+ imagedestroy ($ imgtmp );
5828+ }
58175829 }
58185830 $ this ->addImagePng ($ img , $ file , $ x , $ y , $ w , $ h );
58195831
5820- if ($ img ) {
5832+ if ($ img && PHP_MAJOR_VERSION < 8 ) {
58215833 imagedestroy ($ img );
58225834 }
58235835 }
0 commit comments