Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support automatic width and height calculation of HEIC images #777

Open
djarran opened this issue Jan 17, 2025 · 0 comments
Open

Support automatic width and height calculation of HEIC images #777

djarran opened this issue Jan 17, 2025 · 0 comments

Comments

@djarran
Copy link

djarran commented Jan 17, 2025

Description: When passing an HEIC image to Image without specifying the width and height of the image, it will fail.

In this part of the Image method, we use getimagesize, which returns false as it does not support HEIC. Since $imsize is false, and so are $w and $h, we get the error.

TCPDF/tcpdf.php

Line 6979 in 14ffa0e

if (!empty($imgdata)) {

if (!empty($imgdata)) {
	// copy image to cache
	$original_file = $file;
	$file = TCPDF_STATIC::getObjFilename('img', $this->file_id);
	$fp = TCPDF_STATIC::fopenLocal($file, 'w');
	if (!$fp) {
		$this->Error('Unable to write file: '.$file);
	}
	fwrite($fp, $imgdata);
	fclose($fp);
	unset($imgdata);
	$imsize = @getimagesize($file);
	if ($imsize === FALSE) {
		unlink($file);
		$file = $original_file;
	}
}
if ($imsize === FALSE) {
	if (($w > 0) AND ($h > 0)) {
		// get measures from specified data
		$pw = $this->getHTMLUnitToUnits($w, 0, $this->pdfunit, true) * $this->imgscale * $this->k;
		$ph = $this->getHTMLUnitToUnits($h, 0, $this->pdfunit, true) * $this->imgscale * $this->k;
		$imsize = array($pw, $ph);
	} else {
		$this->Error('[Image] Unable to get the size of the image: '.$file);
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant