Create Image from numerical array of data in php -
My project is working with webservices. I am not sure about the banked logic that how they used to store images in the database.
Aerray ([0] => 11 9 [1] => 80 [2] =
78] [3] => 71 [4] = & gt; 13 [5] => 10 [6] => 26. [3778] => 123 [3779] => 60 [3780] = & gt; -82 [3781] = & gt; -57 [3782] =)
How can this numerical array transform into PNG image?
I have created a new image file and that content in that file using
file_put_contents ('downloads / myImage.png', $ profileImage) ; $ profile image variables include the above an array.
This code creates a new image in which some dumps have datasets. I know that I have missed something by doing this. Please help me with this.
I have used this code to create PDF files from the server in this same project. It's working fine thats why I tried to get my image with the same code but it Not working with images
Your question is a bit unclear ???? I can not tell whether you want to save the PNG file from somewhere or want to distribute it as an answer to an HTTP request. Also, you indicate that $ profileImage is an array variable, but provide it as the argument of file_put_contents () , which expects a string . But by any means, the binary data you provide is fine.
If $ profileImage is an array of signed byte values, you can convert it to a string $ rawPNG = implode ( Array_map ('chr', $ profileImage)); If you need to, then you can use file_put_contents () to write this file in a file. (Function is binary-protected, so there should be no problem.) Alternatively, if you want to return a PNG image to a web client, then echo it with the appropriate content-type header Do:
header ('content-type: image / png'); Die ($ rawPNG);
Comments
Post a Comment