Skip to content

Commit a63f81e

Browse files
committed
Merge branch 'fix/imagedestroy-php85-deprecation'
2 parents a8808b9 + c9a407e commit a63f81e

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

include/tcpdf_images.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ public static function _toPNG($image, $tempfile) {
126126
// create temporary PNG image
127127
imagepng($image, $tempfile);
128128
// remove image from memory
129-
imagedestroy($image);
129+
if (PHP_VERSION_ID < 80000) {
130+
imagedestroy($image);
131+
}
130132
// get PNG image data
131133
$retvars = self::_parsepng($tempfile);
132134
// tidy up by removing temporary image
@@ -145,7 +147,9 @@ public static function _toPNG($image, $tempfile) {
145147
*/
146148
public static function _toJPEG($image, $quality, $tempfile) {
147149
imagejpeg($image, $tempfile, $quality);
148-
imagedestroy($image);
150+
if (PHP_VERSION_ID < 80000) {
151+
imagedestroy($image);
152+
}
149153
$retvars = self::_parsejpeg($tempfile);
150154
// tidy up by removing temporary image
151155
unlink($tempfile);

tcpdf.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7437,12 +7437,16 @@ protected function ImagePngAlpha($file, $x, $y, $wpx, $hpx, $w, $h, $type, $link
74377437
}
74387438
}
74397439
imagepng($imgalpha, $tempfile_alpha);
7440-
imagedestroy($imgalpha);
7440+
if (PHP_VERSION_ID < 80000) {
7441+
imagedestroy($imgalpha);
7442+
}
74417443
// extract image without alpha channel
74427444
$imgplain = imagecreatetruecolor($wpx, $hpx);
74437445
imagecopy($imgplain, $img, 0, 0, 0, 0, $wpx, $hpx);
74447446
imagepng($imgplain, $tempfile_plain);
7445-
imagedestroy($imgplain);
7447+
if (PHP_VERSION_ID < 80000) {
7448+
imagedestroy($imgplain);
7449+
}
74467450
$parsed = true;
74477451
} catch (Exception $e) {
74487452
// GD fails

tcpdf_barcodes_1d.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ public function getBarcodePngData($w=2, $h=30, $color=array(0,0,0)) {
234234
ob_start();
235235
imagepng($png);
236236
$imagedata = ob_get_clean();
237-
imagedestroy($png);
237+
if (PHP_VERSION_ID < 80000) {
238+
imagedestroy($png);
239+
}
238240
return $imagedata;
239241
}
240242
}

tcpdf_barcodes_2d.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ public function getBarcodePngData($w=3, $h=3, $color=array(0,0,0)) {
238238
ob_start();
239239
imagepng($png);
240240
$imagedata = ob_get_clean();
241-
imagedestroy($png);
241+
if (PHP_VERSION_ID < 80000) {
242+
imagedestroy($png);
243+
}
242244
return $imagedata;
243245
}
244246
}

0 commit comments

Comments
 (0)