我无法在网页中显示jp2图像。
这是从数据库获取图像并将其显示在网页中的主文件。
数据库中的图像格式为JP2图像格式。
<?php
echo' <html>';
echo'<body>';
echo' <table>';
echo' <tr><td>';
$dbcnx = @mysql_connect('127.0.0.1', 'root', 'root@19211');
if (!$dbcnx) {
die('<p>Unable to connect to the ' . 'database server at this time.</p>'
);
}
if (!@mysql_select_db('finaldb')) {
die('<p>Unable to locate the ' . 'database at this time.</p>');
}
$selectrc = 'select BPFT_Photo from photo_templates limit 1';
$result = @mysql_query($selectrc, $dbcnx);
if (!$result) {
die('<p>Error performing query: ' . mysql_error() . '</p>');
} else {
}
$n = mysql_num_rows($result);
$row = mysql_fetch_assoc($result);
$Photo_Details = $row['BPFT_Photo'];
$residentPhoto = getResidentPhoto();
$image_type_to_mime_type0 =image_type_to_mime_type($residentPhoto)
header('Content-type:$image_type_to_mime_type0');
echo' '.$residentPhoto;
echo'</td>';
echo'</tr>';
echo'</table>';
echo'</body>';
echo'</html>';
?>
答案 0 :(得分:0)
jp2图像必须在浏览器中支持,否则你无法看到..
以及您在网页中添加它的方法
(我认为你使用了回声)。但是回声没有什么可以只写一些字符到网页
您必须从数据库获取图像并将其保存在服务器的临时文件夹中并回显Web的路径
示例:
$path="root/tmp/photo.jp2";
echo '<img src=$path>';
答案 1 :(得分:0)
Remember that header() must be called before any actual output is sent
以上一行来自php.net。 您正在使用标头请求,但您已经回显了一些数据,因此已经发送了标头。
如果您想显示 JP2 数据,您有两个选项:
<img>
标记加载图片。header(Content-type)
方法,但只输出图像数据,不包含表格,而不是 JP2原始数据。<强>更新强>
在数年和数年之后,还要查看here关于JPEG-2000格式的非常小的支持。如果我是你,我会改变我对网上 JP2用法的想法..