I have an image that is being fed to my PHP script as binary data. I want to save this image as a jpeg to a directory on my server. I can accomplish this with the following code:
// create image resource from the binary data
$image = imagecreatefromstring($binary_data);
// save the image resource as a jpeg
imagejpeg($image, $directory);
The problem is that when I do this, I think it is creating a new image that contains new metadata. Is there a way I can save the binary data as an image and preserve the original binary data?