@@ -5658,7 +5658,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
56585658 // Cast to 8bit+palette
56595659 $ imgalpha_ = @imagecreatefrompng ($ tempfile_alpha );
56605660 imagecopy ($ imgalpha , $ imgalpha_ , 0 , 0 , 0 , 0 , $ wpx , $ hpx );
5661- imagedestroy ($ imgalpha_ );
5661+ if (PHP_MAJOR_VERSION < 8 ) {
5662+ imagedestroy ($ imgalpha_ );
5663+ }
56625664 imagepng ($ imgalpha , $ tempfile_alpha );
56635665 } else {
56645666 $ tempfile_alpha = null ;
@@ -5711,7 +5713,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
57115713 // extract image without alpha channel
57125714 $ imgplain = imagecreatetruecolor ($ wpx , $ hpx );
57135715 imagecopy ($ imgplain , $ img , 0 , 0 , 0 , 0 , $ wpx , $ hpx );
5714- imagedestroy ($ img );
5716+ if (PHP_MAJOR_VERSION < 8 ) {
5717+ imagedestroy ($ img );
5718+ }
57155719
57165720 imagepng ($ imgalpha , $ tempfile_alpha );
57175721 imagepng ($ imgplain , $ tempfile_plain );
@@ -5722,13 +5726,17 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
57225726 // embed mask image
57235727 if ($ tempfile_alpha ) {
57245728 $ this ->addImagePng ($ imgalpha , $ tempfile_alpha , $ x , $ y , $ w , $ h , true );
5725- imagedestroy ($ imgalpha );
5729+ if (PHP_MAJOR_VERSION < 8 ) {
5730+ imagedestroy ($ imgalpha );
5731+ }
57265732 $ this ->imageCache [] = $ tempfile_alpha ;
57275733 }
57285734
57295735 // embed image, masked with previously embedded mask
57305736 $ this ->addImagePng ($ imgplain , $ tempfile_plain , $ x , $ y , $ w , $ h , false , ($ tempfile_alpha !== null ));
5731- imagedestroy ($ imgplain );
5737+ if (PHP_MAJOR_VERSION < 8 ) {
5738+ imagedestroy ($ imgplain );
5739+ }
57325740 $ this ->imageCache [] = $ tempfile_plain ;
57335741 }
57345742
@@ -5813,11 +5821,13 @@ function addPngFromFile($file, $x, $y, $w = 0, $h = 0)
58135821 }
58145822
58155823 imagecopy ($ img , $ imgtmp , 0 , 0 , 0 , 0 , $ sx , $ sy );
5816- imagedestroy ($ imgtmp );
5824+ if (PHP_MAJOR_VERSION < 8 ) {
5825+ imagedestroy ($ imgtmp );
5826+ }
58175827 }
58185828 $ this ->addImagePng ($ img , $ file , $ x , $ y , $ w , $ h );
58195829
5820- if ($ img ) {
5830+ if ($ img && PHP_MAJOR_VERSION < 8 ) {
58215831 imagedestroy ($ img );
58225832 }
58235833 }
0 commit comments