+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 21

Thread: Binary Images are going to kill me

  1. #1
    Join Date
    Sep 2005
    Posts
    1

    Default Binary Images are going to kill me

    I'm running PHP 5.0.4 on Windows Server 2003.

    I'm currently working on a real estate website that dynamically pulls information from a RETS server. This server holds data about homes for sale on the MLS. Here is the problem:

    I'm trying to pull the images of a house from the server. I get all of the header information and then the binary data stream (I think it's bindary) as seen below. I am trying to display this image:





    [CODE]HTTP/1.1 200 OK
    Date: Wed, 21 Sep 2005 01:05:24 GMT
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET (03)
    X-AspNet-Version: 1.1.4322
    MIME-Version: 1.0
    Object-ID: 1
    Content-Description:
    Content-Length: 28211
    RETS-Version: RETS/1.5
    Cache-Control: private
    Content-Type: image/jpeg

    Code:
    JFIFKKC  
    
     $.' ",#(7),01444'9=82<.342C     
    
    2!!22222222222222222222222222222222222222222222222222," 
    ĵ}!1AQa"q2#BR$3br 
    %&'()*456789& #58;CDEFGHIJSTUVWXYZcdefghijstuvwxyz
     
    ĵw!1AQaq"2B #3Rbr
    $4%&'()*56789& #58;CDEFGHIJSTUVWXYZcdefghijstuvwxyz
     ?"p@:JHG*Q /)CA
    J((]"~B]"F))n>|7EE.(&?N})1K>/(I?Fh)>  ϰ?!E~B4qA
    Ky..%Hany=q^<e&{5ڄ&j>(ҽwWb3տ⸍_WP 
    M;(~Mh껕pfQ(노5f%%G&=+H-<I *mIGFoc4;L ?n ;c>pWA۸A@<Gkڋ=PD8ogEj`}(}!\uqik>Kz^*zi= NA
    7A
    J)  6PA
    7A
    m~B~B>d~BE.  (plus many more characters...)
    We have a PHP function that strips off the header information from the RETS server (that you now see above) so that all that remains is the binary data stream. Also, I am setting the headers on this particular page to content-type = image\jpeg and content-length = strlen(binarystream). I then reference this PHP page from the page that I am wanting to display the image on by <img src="displayimage.php">. From everything Ive seen, this should work however, all we get is a broken image link. Is there anything we should be or should not be doing to the binary data stream in order to display this data as an image?

    Thanks for the help...

  2. #2
    Aaron is offline Real Estate Webmasters Staff Aaron's Most Recent Blog Entry: Email etiquette Aaron is on a distinguished road
    Join Date
    Jun 2005
    Location
    Nanaimo
    Posts
    23,421

    Default Re: Binary Images are going to kill me

    Hi ... Is getting the binary data for the is the only option? I have set up a connection with a RETS server, and I was able to just download the full image file, but anyways... Maybe something like this will help you ...

    file1.php
    Code:
    <html>
    
    <body>
    
    <img src="1b.php">
    
    </body>
    
    </html>
    file2.php
    Code:
    <?php
    
        header("Content-type: img/jpeg");
    
        $filename = "filename.jpg";
    
        $fp = fopen($filename,  "rb");
    
        $image = fread($fp, filesize($filename));
    
        fclose($fp);
    
        echo $image;
    
    ?>

  3. #3
    Join Date
    May 2006
    Posts
    34

    Default Re: Binary Images are going to kill me

    Did you ever get this figured out?

    I am running into the same problems.

  4. #4
    Aaron is offline Real Estate Webmasters Staff Aaron's Most Recent Blog Entry: Email etiquette Aaron is on a distinguished road
    Join Date
    Jun 2005
    Location
    Nanaimo
    Posts
    23,421

    Default Re: Binary Images are going to kill me

    Not really, seems to be very difficult to pull images from a RETS server.
    I continue to run into this problem also.

  5. #5
    Join Date
    May 2006
    Posts
    34

    Default Re: Binary Images are going to kill me

    I don't have a problem getting the images, but they come down encoded, but I can't figure out how they are encoded.

    I am using PHP and have tried decoding them using every method I can think of.

    Are you even able to pull the binary? If not I can give you my PHP code that does it.

  6. #6
    Join Date
    Sep 2005
    Posts
    62

    Default Re: Binary Images are going to kill me

    All images are binary. You have to write them as binary objects not as text objects.

    Also, 99.9% of MLS's do not allow you to dynamically pull images for each display liek that. You have to download them locally once and use them from your local system.

  7. #7
    Join Date
    Apr 2006
    Posts
    211

    Default Re: Binary Images are going to kill me

    Like RobertD said, all images are binary. Looks like the code example you've posted is in ASCII. I don't know if your MLS is storing the pics in their database in BLOB (Binary Large Object) fields - instead of in a simple folder as complete MIME files, which is a lot faster - but it's a bad idea if they are because you have to reconstruct them pixel-by-pixel...and then store them. At any rate, you're getting the wrong data type.

  8. #8
    Join Date
    Sep 2005
    Posts
    62

    Default Re: Binary Images are going to kill me

    No, it's not the way the MLS is storing them or sending them. It's 100% the way that they are writing them. The photos are sent as binary streams, and you have to write the photos as binary objects.

  9. #9
    Join Date
    Apr 2006
    Posts
    211

    Default Re: Binary Images are going to kill me

    In that case you can do it out of the PHP Manual.

  10. #10
    Join Date
    May 2006
    Posts
    34

    Default Re: Binary Images are going to kill me

    I have tried everything I could think of to get the binary stream to form into a picture using the GD library. I was unable to figure it out.

    Instead, I just use the fget and similiar commands to pull the image straight from their server and store it locally.

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts