0

我有一个图像作为二进制数据输入我的 PHP 脚本。我想将此图像作为 jpeg 保存到我服务器上的目录中。我可以使用以下代码完成此操作:

// create image resource from the binary data
$image = imagecreatefromstring($binary_data);

// save the image resource as a jpeg
imagejpeg($image, $directory);

问题是当我这样做时,我认为它正在创建一个包含新元数据的新图像。有没有办法可以将二进制数据保存为图像并保留原始二进制数据?

4

2 回答 2

0

With Meta data, you can read the data via iptcparse() and embed it back in via iptcembed()

This comment will pretty much do exactly what you want -> http://us3.php.net/manual/en/function.iptcembed.php#85887

For EXIF data, you can read it via exif-read-data() but there isn't a way of writing that data back to the file, but hopefully that should be enough to get you started in the right direction.

于 2012-05-04T07:20:44.450 回答
0

你为什么不直接保存$binary_data而不是通过 GD
file_put_contents($directory, $binary_data)

于 2012-05-03T20:00:54.287 回答