显示php图像
我正在尝试将形状显示到html站点中。该形状表示条形图。我试图显示图像,但每次我运行该网站时,它都会显示一个断开的图像链接 这是整个文件显示php图像,php,image,Php,Image,我正在尝试将形状显示到html站点中。该形状表示条形图。我试图显示图像,但每次我运行该网站时,它都会显示一个断开的图像链接 这是整个文件 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>psdtoweb120715EmailSummary1195.psd</title>
<link type="text/css">
</head>
<style >
{
body, table, tr, td, p {
margin: 0;
padding: 0;
}
</style>
<body margin = "0" padding = "0">
<table width = "100%" height = "826"margin = "0" padding = "0">
<tr margin = "0" padding = "0">
<td width = "25%" margin = "0" padding = "0"> </td>
<td margin = "0" padding = "0">
<table margin = "0" padding = "0" width = "612" height = "826" background= "http://piqdev.myperformanceiq.com/brian/images/bckgrnd1.png" style="background-repeat:no-repeat;>
<tr margin = "0" padding = "0">
<td valign = "top"> <p style= "margin:0; padding-left: 20px; text-transform: uppercase;font-size: 30pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;" >Steve.b</p></td>
<td colspan = "2" valign = "top" align = "right" style = "padding-left:100px; padding-right: 10px"><p style= " display: relative;margin:0; padding-top: 5px;font-size: 12pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;"> Result summary for: <span style= "margin:0; font-size: 15pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;"> 8/20/15</span><br/>55 Minutes (6:00 am - 6:55am) </p></td>
</tr>
<tr margin = "0" padding = "0" height = "10%" display = "relative">
<td valign = "top" margin = "0" padding = "0" style= "margin:0; padding-bottom: 60px;font-size: 70pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;"><p style = "padding-left: 100px; padding-bottom: 390px; " >500 </p></td>
<td valign = "top" margin = "0" padding = "0" style= "margin:0; font-size: 40pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;"><p style = "padding-left: 50px; padding-top: 20px;padding-bottom: 10px;">300 <br/><div style = "padding-left: 55px;padding-top:0px; ">600 </div></td>
<td valign = "top" margin = "0" padding = "0" style= "margin:0; font-size: 40pt; color: #ffffff;font-family: Calibri, Georgia, Serif; font-weight: bold;"><p style = "padding-top: 20px; padding-left: 20px; padding-right: 42px; ">200 <br/> <div style = "padding-left: 15px; padding-top:13px; font-size:35pt;" >3/12 </div></td>
</tr>
<tr>
<td>
<?php
// Create a 200 x 200 image
$canvas = imagecreatetruecolor(200, 200);
// Allocate colors
$red = imagecolorallocate($canvas, 255, 0, 0);
$blue = imagecolorallocate($canvas, 55, 149, 255);
$green = imagecolorallocate($canvas, 5, 186, 78);
$yellow = imagecolorallocate($canvas, 219, 255, 70);
$orange= imagecolorallocate($canvas, 255, 212, 36);
// Draw three rectangles each with its own color
imageFilledRectangle($canvas, 0, 120, 40, 200, $blue);
imageFilledRectangle($canvas, 80, 200, 40, 100, $green);
imageFilledRectangle($canvas, 115, 200,81, 120, $yellow);
imageFilledRectangle($canvas, 115, 150, 155, 200, $orange);
imageFilledRectangle($canvas, 155, 160, 200, 200, $red);
// Output and free from memory
header('Content-Type: image/jpeg');
imagejpeg($canvas);
imagedestroy($canvas);
?>
<img src= "<?php echo $canvas; ?>"/>
</td>
</tr>
</table>
</td>
<td width = "25%"> </td>
</tr>
</table>
psdtoweb120715电子邮件摘要1195.psd
{
阀体、工作台、tr、td、p{
保证金:0;
填充:0;
}
将此代码块放在另一个文件中,称之为“showimage.php”
图像源必须是文件指针,而不是图像生成器代码的回音。将此代码块放在另一个文件中,称之为“showimage.php”
图像源需要是一个文件指针,而不是图像生成器代码的回音。虽然我更喜欢@Fred的方法,但实际上您可以用不同的方法来实现
<tr>
<td>
<?php
// Create a 200 x 200 image
$canvas = imagecreatetruecolor(200, 200);
// Allocate colors
$red = imagecolorallocate($canvas, 255, 0, 0);
$blue = imagecolorallocate($canvas, 55, 149, 255);
$green = imagecolorallocate($canvas, 5, 186, 78);
$yellow = imagecolorallocate($canvas, 219, 255, 70);
$orange= imagecolorallocate($canvas, 255, 212, 36);
// Draw three rectangles each with its own color
imageFilledRectangle($canvas, 0, 120, 40, 200, $blue);
imageFilledRectangle($canvas, 80, 200, 40, 100, $green);
imageFilledRectangle($canvas, 115, 200,81, 120, $yellow);
imageFilledRectangle($canvas, 115, 150, 155, 200, $orange);
imageFilledRectangle($canvas, 155, 160, 200, 200, $red);
ob_start();
imagejpeg($canvas);
$buffer = ob_get_clean();
imagedestroy($canvas);
?>
<img src= "<?php echo "data:image/jpeg;base64," . base64_encode($buffer); ?>"/>
</td>
</tr>
"/>
您最初的问题是,您只是试图将原始二进制图像数据放入
标记中,但您不能这样做。它需要是一个外部文件,或者是正确编码的数据
这实际上会将图像作为base64嵌入到页面中,从而阻止第二个HTTP请求。请注意,这会使页面更大,无法下载,并且会阻止缓存图像,因此不建议在大多数情况下使用
正如@Dagon在评论中指出的那样,一些较旧的浏览器不支持此功能,但大多数现代浏览器都支持此功能。虽然我更喜欢@Fred的方法,但实际上您可以用不同的方式来实现
<tr>
<td>
<?php
// Create a 200 x 200 image
$canvas = imagecreatetruecolor(200, 200);
// Allocate colors
$red = imagecolorallocate($canvas, 255, 0, 0);
$blue = imagecolorallocate($canvas, 55, 149, 255);
$green = imagecolorallocate($canvas, 5, 186, 78);
$yellow = imagecolorallocate($canvas, 219, 255, 70);
$orange= imagecolorallocate($canvas, 255, 212, 36);
// Draw three rectangles each with its own color
imageFilledRectangle($canvas, 0, 120, 40, 200, $blue);
imageFilledRectangle($canvas, 80, 200, 40, 100, $green);
imageFilledRectangle($canvas, 115, 200,81, 120, $yellow);
imageFilledRectangle($canvas, 115, 150, 155, 200, $orange);
imageFilledRectangle($canvas, 155, 160, 200, 200, $red);
ob_start();
imagejpeg($canvas);
$buffer = ob_get_clean();
imagedestroy($canvas);
?>
<img src= "<?php echo "data:image/jpeg;base64," . base64_encode($buffer); ?>"/>
</td>
</tr>
"/>
您最初的问题是,您只是试图将原始二进制图像数据放入
标记中,但您不能这样做。它需要是一个外部文件,或者是正确编码的数据
这实际上会将图像作为base64嵌入到页面中,从而阻止第二个HTTP请求。请注意,这会使页面更大,无法下载,并且会阻止缓存图像,因此不建议在大多数情况下使用
正如@Dagon在评论中指出的,一些旧浏览器不支持此功能,但大多数现代浏览器都支持此功能。img tag src属性需要一个URL,在本例中,该URL就是上面的php文件。我试图将php标记放在html文件中。这仍然有效吗?“我试图将php标记放在html文件中。”-.html
?img tag src属性需要一个URL,在本例中,该URL将是上面的php文件。我试图将php标记放入html文件中。这仍然有效吗?“我试图将php标记放入html文件中。”-.html
?另一个缺点是,一些客户端不支持数据:image/png;base64
几乎所有现代浏览器都支持它。没有人再为IE6开发了:)时代在变!我遇到了手机问题我添加了一个说明,谢谢:)Android内置浏览器和iOS上的Chrome和Safari支持它,但旧版r版本可能不支持,不太流行的移动操作系统也可能不支持。另一个缺点是,一些客户端不支持数据:image/png;base64
几乎所有现代浏览器都支持它。没有人再为IE6开发了:)时代在变!我遇到了手机/手机问题我补充了一条说明,谢谢:)Android内置浏览器和Chrome和iOS上的Safari支持它,但旧版本可能不支持,不太流行的移动操作系统也可能不支持。
<tr>
<td>
<img src= "showimage.php" />
</td>
</tr>
<tr>
<td>
<?php
// Create a 200 x 200 image
$canvas = imagecreatetruecolor(200, 200);
// Allocate colors
$red = imagecolorallocate($canvas, 255, 0, 0);
$blue = imagecolorallocate($canvas, 55, 149, 255);
$green = imagecolorallocate($canvas, 5, 186, 78);
$yellow = imagecolorallocate($canvas, 219, 255, 70);
$orange= imagecolorallocate($canvas, 255, 212, 36);
// Draw three rectangles each with its own color
imageFilledRectangle($canvas, 0, 120, 40, 200, $blue);
imageFilledRectangle($canvas, 80, 200, 40, 100, $green);
imageFilledRectangle($canvas, 115, 200,81, 120, $yellow);
imageFilledRectangle($canvas, 115, 150, 155, 200, $orange);
imageFilledRectangle($canvas, 155, 160, 200, 200, $red);
ob_start();
imagejpeg($canvas);
$buffer = ob_get_clean();
imagedestroy($canvas);
?>
<img src= "<?php echo "data:image/jpeg;base64," . base64_encode($buffer); ?>"/>
</td>
</tr>