Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions include/tcpdf_images.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ public static function _toPNG($image, $tempfile) {
// create temporary PNG image
imagepng($image, $tempfile);
// remove image from memory
imagedestroy($image);
if (PHP_VERSION_ID < 80000) {
imagedestroy($image);
}
// get PNG image data
$retvars = self::_parsepng($tempfile);
// tidy up by removing temporary image
Expand All @@ -145,7 +147,9 @@ public static function _toPNG($image, $tempfile) {
*/
public static function _toJPEG($image, $quality, $tempfile) {
imagejpeg($image, $tempfile, $quality);
imagedestroy($image);
if (PHP_VERSION_ID < 80000) {
imagedestroy($image);
}
$retvars = self::_parsejpeg($tempfile);
// tidy up by removing temporary image
unlink($tempfile);
Expand Down
8 changes: 6 additions & 2 deletions tcpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -7437,12 +7437,16 @@ protected function ImagePngAlpha($file, $x, $y, $wpx, $hpx, $w, $h, $type, $link
}
}
imagepng($imgalpha, $tempfile_alpha);
imagedestroy($imgalpha);
if (PHP_VERSION_ID < 80000) {
imagedestroy($imgalpha);
}
// extract image without alpha channel
$imgplain = imagecreatetruecolor($wpx, $hpx);
imagecopy($imgplain, $img, 0, 0, 0, 0, $wpx, $hpx);
imagepng($imgplain, $tempfile_plain);
imagedestroy($imgplain);
if (PHP_VERSION_ID < 80000) {
imagedestroy($imgplain);
}
$parsed = true;
} catch (Exception $e) {
// GD fails
Expand Down
4 changes: 3 additions & 1 deletion tcpdf_barcodes_1d.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ public function getBarcodePngData($w=2, $h=30, $color=array(0,0,0)) {
ob_start();
imagepng($png);
$imagedata = ob_get_clean();
imagedestroy($png);
if (PHP_VERSION_ID < 80000) {
imagedestroy($png);
}
return $imagedata;
}
}
Expand Down
4 changes: 3 additions & 1 deletion tcpdf_barcodes_2d.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ public function getBarcodePngData($w=3, $h=3, $color=array(0,0,0)) {
ob_start();
imagepng($png);
$imagedata = ob_get_clean();
imagedestroy($png);
if (PHP_VERSION_ID < 80000) {
imagedestroy($png);
}
return $imagedata;
}
}
Expand Down