Your question is a little bit unclear — I can't tell if you want to save the PNG file somewhere or deliver it as the response to an HTTP request. Also, you seem to imply that $profileImage
is an array variable, but provide it as an argument to file_put_contents()
, which expects a string.
But either way, the binary data you are being provided with looks fine.
If $profileImage
is an array of signed byte values, then you can convert it to a string of binary data with the following command"
$rawPNG = implode(array_map('chr',$profileImage));
If you need to, you can then use file_put_contents()
to write this data to a file. (The function is binary-safe, so there shouldn't be any problems.)
Alternatively, if you want to return a PNG image to a web client, just echo it with an appropriate Content-Type header:
header('Content-Type: image/png');
die ($rawPNG);