FPDF错误:不支持的图像类型(使用标头定义图像时)


FPDF error: Unsupported image type (while using header to define image)

所以我有一个图像字符串,我插入到一个网页中,其中有一个标题告诉浏览器这是一个图像。

所以一个页面看起来是这样的:

<?php
    header('Content-Type: image/png');
    echo $image_data;
?>

http://website.com/randomString.png用于获取图像(使用.htaccess)

当我使用以下代码时,我得到错误FPDF error: Unsupported image type

$imagePath = file_get_contents("http://website.com/".$randomString.".png");
$pdf->Image($imagePath,159,185,27);

有人知道我能做些什么来消除这个错误吗?

Image替换为MemImage(并从下面的列表中复制类或自己复制函数),否则它希望从文件中读取图像。

http://www.fpdf.org/en/script/script45.php