Jump to content

Displaying a binary image


Recommended Posts

I would like to know if anyone knows how I could go about sending an image to the browser that is binary. 

Here is what I am doing right now...but it's not working:

 

header("Content-Type: image/jpeg");
header('Content-Disposition: inline; filename="image.jpg"');
$theImage = $thePage->GetAs("image.jpg", 350, 270, 60);
imagejpeg($theImage);

 

I have an ASP script that I am going off of to pull this together, and it uses "Response.BinaryWrite", is there an equivalent in PHP?

Link to comment
https://forums.phpfreaks.com/topic/51816-displaying-a-binary-image/
Share on other sites

That's what I thought...But my result is a page with the page URL printed in the browser window, and no source code...And when I right click the text, it shows up like it is an image...ie "Copy Image", "Copy Image Location"....Etc.

 

<?php
if(isset($_GET['submit']))
  {
$url=$_GET['site'];

$thePage = new COM("ABCDrawHTML2.Page");
$thePage->Url = ($url);
header("Content-Type: image/jpeg");
header('Content-Disposition: inline; filename="image.jpg"');
$theImage = $thePage->GetAs("image.jpg", 350, 270, 60);


$thePage->Save('C:/wamp/www/'.$url.'.jpg');
}
?>

 

The image saves fine, but I am trying to avoid saving it, because I will be accessing this from a different server, and I don't want the images to overload my home computer. 

Here is the full code:

 

<?php
if(isset($_GET['submit']))
  {
$url=$_GET['site'];

$thePage = new COM("ABCDrawHTML2.Page");
$thePage->Url = ($url);
$theImage = $thePage->GetAs("image.jpg", 350, 270, 60);
header("Content-Type: image/jpeg");
header('Content-Disposition: inline; filename="image.jpg"');
imagejpeg($theImage);

$thePage->Save('C:/wamp/www/'.$url.'.jpg');
}


echo'
<form method="get" action="david.php">
<input type="text" name="site"/>
<input type="submit" name="submit"/>
</form>
';

?>

 

It doesn't even echo the form or the image at the end of the script.....The script stops without any errors for no apparent reason...I moved the ->GetAs, and the script continued until it came to that, and just quit....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.