@@ -6050,7 +6050,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
60506050 // Cast to 8bit+palette
60516051 $ imgalpha_ = @imagecreatefrompng ($ tempfile_alpha );
60526052 imagecopy ($ imgalpha , $ imgalpha_ , 0 , 0 , 0 , 0 , $ wpx , $ hpx );
6053- imagedestroy ($ imgalpha_ );
6053+ if (PHP_MAJOR_VERSION < 8 ) {
6054+ imagedestroy ($ imgalpha_ );
6055+ }
60546056 imagepng ($ imgalpha , $ tempfile_alpha );
60556057
60566058 // Make opaque image
@@ -6105,7 +6107,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
61056107 // Cast to 8bit+palette
61066108 $ imgalpha_ = @imagecreatefrompng ($ tempfile_alpha );
61076109 imagecopy ($ imgalpha , $ imgalpha_ , 0 , 0 , 0 , 0 , $ wpx , $ hpx );
6108- imagedestroy ($ imgalpha_ );
6110+ if (PHP_MAJOR_VERSION < 8 ) {
6111+ imagedestroy ($ imgalpha_ );
6112+ }
61096113 imagepng ($ imgalpha , $ tempfile_alpha );
61106114 } else {
61116115 $ tempfile_alpha = null ;
@@ -6159,7 +6163,9 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
61596163 // extract image without alpha channel
61606164 $ imgplain = imagecreatetruecolor ($ wpx , $ hpx );
61616165 imagecopy ($ imgplain , $ img , 0 , 0 , 0 , 0 , $ wpx , $ hpx );
6162- imagedestroy ($ img );
6166+ if (PHP_MAJOR_VERSION < 8 ) {
6167+ imagedestroy ($ img );
6168+ }
61636169
61646170 imagepng ($ imgalpha , $ tempfile_alpha );
61656171 imagepng ($ imgplain , $ tempfile_plain );
@@ -6170,13 +6176,17 @@ protected function addImagePngAlpha($file, $x, $y, $w, $h, $byte)
61706176 // embed mask image
61716177 if ($ tempfile_alpha ) {
61726178 $ this ->addImagePng ($ imgalpha , $ tempfile_alpha , $ x , $ y , $ w , $ h , true );
6173- imagedestroy ($ imgalpha );
6179+ if (PHP_MAJOR_VERSION < 8 ) {
6180+ imagedestroy ($ imgalpha );
6181+ }
61746182 $ this ->imageCache [] = $ tempfile_alpha ;
61756183 }
61766184
61776185 // embed image, masked with previously embedded mask
61786186 $ this ->addImagePng ($ imgplain , $ tempfile_plain , $ x , $ y , $ w , $ h , false , ($ tempfile_alpha !== null ));
6179- imagedestroy ($ imgplain );
6187+ if (PHP_MAJOR_VERSION < 8 ) {
6188+ imagedestroy ($ imgplain );
6189+ }
61806190 $ this ->imageCache [] = $ tempfile_plain ;
61816191 }
61826192
@@ -6261,11 +6271,13 @@ function addPngFromFile($file, $x, $y, $w = 0, $h = 0)
62616271 }
62626272
62636273 imagecopy ($ img , $ imgtmp , 0 , 0 , 0 , 0 , $ sx , $ sy );
6264- imagedestroy ($ imgtmp );
6274+ if (PHP_MAJOR_VERSION < 8 ) {
6275+ imagedestroy ($ imgtmp );
6276+ }
62656277 }
62666278 $ this ->addImagePng ($ img , $ file , $ x , $ y , $ w , $ h );
62676279
6268- if ($ img ) {
6280+ if ($ img && PHP_MAJOR_VERSION < 8 ) {
62696281 imagedestroy ($ img );
62706282 }
62716283 }
0 commit comments