Solved

Convert Binary String to Image and store locally

Posted on 2008-06-26
2
1,309 Views
Last Modified: 2013-12-12
I'm hoping this question is fairly simple but i'm having some trouble with it.
I'm trying to convert a binary string into an image.  I'm using a system where you call a web service to request an image and they send it back in binary format.  I'm to use this to store the file locally.  I"m having trouble storing this locally.

Here is some information about the data being returned:

MIME-Version: 1.0
Transfer-Encoding: chunked
Cache-Control: private
Content-Type: multipart/parallel; boundary="AABBCCDD"; charset=utf-8

And this is an example of the binary data being returned that i want to store as an image:

--AABBCCDD Content-Type: image/jpeg Content-ID: 1234 Object-ID: 0 ýýýýJFIF``ýýC    $.' ",#(7),01444'9=82<.342ýýC  2!! ... --AABBCCDD--

I know this data has boundaries set so i need to grab what's in between and store the image locally.  I'm hoping this can be done in PHP.

If more information is needed please let me know.
Any and all help is much appreciated.
Thanks in advance.

Adam
0
Comment
Question by:ahanley409
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
virmaior earned 500 total points
ID: 21883346
how are you getting the image?

that looks like curl output.

what are you getting the data from?  (that would determine what you need to do in order to clip the headers).

basically, something like this:
$start_pos = strpos($my_string,'ýýýý');
$my_image = substr($my_string,$start_post,strlen($my_string) - $start_pos);
$my_file = fopen('c:\\temp\\temp.jpg','w');
fwrite($my_file,$my_image);
fclose($my_file);
0
 

Author Closing Comment

by:ahanley409
ID: 31471134
Yes it was curl output :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question