I am creating an image on the fly with PHP:
Code: Select all
<img src='scripts/sig.php?q=".$vehicleid."|".$vcdate."&sid=".rand()."' height='80px' width='240px' />Any ideas would be greatly appreciated.
Thanks in advance
Rob
Moderator: General Moderators
Code: Select all
<img src='scripts/sig.php?q=".$vehicleid."|".$vcdate."&sid=".rand()."' height='80px' width='240px' />Code: Select all
<img src='scripts/sig.php?q=".$vehicleid."!".$vcdate."&sid=".rand()."' height='80px' width='240px' />Code: Select all
<img src='scripts/sig.php?q=".$vehicleid."!".$vcdate."&sid=".rand()."' height='80px' width='240px' />Code: Select all
echo "<img src='scripts/sig.php?q=" . $vehicleid . "!" . $vcdate. "&sid=" . rand() . "' height='80' width='240' />";Code: Select all
<img src="scripts/sig.php?q=<?php echo $vehicleid; ?>!<?php echo $vcdate; ?>&sid=<?php echo rand() ?>" height="80" width="240" /> Code: Select all
echo "<td colspan='5'><img src='scripts/sig.php?q=".$vehicleid."!".$vcdate."&sid=".rand()."' height='80' width='240' /></td></td>";Code: Select all
<?php
$q=$_GET["q"];
$qa=explode("!",$q);
//Get Signature Data
$sql="SELECT vcdata FROM vehiclecheck WHERE vehicleid='".$qa[0]."' AND vcdate='".$qa[1]."'";
$res=mysql_query($sql);
$row=mysql_fetch_array($res);
$vcdata=explode("|",$row['vcdata']);
$plot=$vcdata[16];
//Draw Signature
$im = @imagecreatetruecolor(240, 80)
or die("Cannot Initialize new GD image stream");
$black=imagecolorallocate($im, 1, 1, 1);
$bg=imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg);
$sigpos=0;
while($sigpos<strlen($plot))
{
$plotX=intval(hexdec(substr($plot,$sigpos,2)));
$plotY=intval(hexdec(substr($plot,$sigpos+2,2)));
if($plotY>127)
{
$plotXold=$plotX;
$plotYold=$plotY-128;
}
else
{
imageline($im,$plotXold,$plotYold,$plotX,$plotY,$black);
$plotXold=$plotX;
$plotYold=$plotY;
}
$sigpos=$sigpos+4;
}
// Turn on output buffering
ob_start();
imagejpeg($im);
header("Content-type: image/jpeg");
// Tell the browser the number of bytes in buffer
header("Content-Length: " . ob_get_length());
// Send the buffer to the browser
ob_end_flush();
// Free the memory
imagedestroy($im);
exit;
?>Code: Select all
echo "<td colspan='5'><img src='scripts/sig.php?q=".$vehicleid."!".$vcdate."&sid=".rand().".jpg' height='80' width='240' /></td>";Code: Select all
echo "<img src='scripts/sig.php?id=".$vehicleid."&date=".$vcdate."&sid=".rand()."' height='80px' width='240px' />"; Simplifying the script makes it easier to determine what is wrong.robshanks wrote:Thanks Zoxive
But the problem isn't producing the image, that is produced fine.
The only issue is IE7 will not print the image. IE7 displays it correctly, Firefox both displays it and prints it correctly.
Code: Select all
header("Content-type: image/jpeg");
imagejpeg($im); // Should be after Header
Code: Select all
<?php
header("Content-type: image/jpeg");
$im = @imagecreatetruecolor(240, 80)
or die("Cannot Initialize new GD image stream");
$black=imagecolorallocate($im, 1, 1, 1);
$bg=imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg);
imagestring($im,3,1,1,"Help! Won't print in IE7",$black);
imagejpeg($im);
imagedestroy($im);
exit;
?>Code: Select all
<?php
$plot=$_GET["q"];
$im = @imagecreatetruecolor(240, 80)
or die("Cannot Initialize new GD image stream");
$black=imagecolorallocate($im, 1, 1, 1);
$bg=imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg);
$sigpos=0;
while($sigpos<strlen($plot))
{
$plotX=intval(hexdec(substr($plot,$sigpos,2)));
$plotY=intval(hexdec(substr($plot,$sigpos+2,2)));
if($plotY>127)
{
$plotXold=$plotX;
$plotYold=$plotY-128;
}
else
{
imageline($im,$plotXold,$plotYold,$plotX,$plotY,$black);
$plotXold=$plotX;
$plotYold=$plotY;
}
$sigpos=$sigpos+4;
}
// Turn on output buffering
ob_start();
imagejpeg($im);
header("Content-type: image/jpeg");
// Tell the browser the number of bytes in buffer
header("Content-Length: " . ob_get_length());
// Send the buffer to the browser
ob_end_flush();
// Free the memory
imagedestroy($im);
exit;
?>The image and the header are sent to the buffer and then the buffer is sent to the browser.Zoxive wrote:
It could also be, because you are setting your headers after you send the image data.
PHP:
header("Content-type: image/jpeg");
imagejpeg($im); // Should be after Header