我在服务器上通过cURL下载了一张图片。下载很好,但是它覆盖了图像中的exif数据。我使用代码点火器4。
我希望在下载之前或之后,使用PHP或javascript获取图像中包含的exif数据。这些数据必须存储在我的数据库(gps等)我的代码中:
public function test()
{
$client = \Config\Services::curlrequest();
$kobo_url = 'https://kc.humanitarianresponse.infoxxxxxx.png';
$response = $client->request('GET',$kobo_url , [
'auth' => ['user', 'My Password'] ]);
//echo $response->getStatusCode();
$resultat = $response->getBody();
$img_path = './assets/images/kobo/test.png';
$fp = fopen($img_path, 'x');
fwrite($fp, $resultat);
fclose($fp);
$exif = exif_read_data($resultat);
var_dump ($exif);
}谢谢。
发布于 2021-06-03 14:09:30
我终于找到了解决办法。通过使用“复制”,exif数据不会被更改。还插入用户名和密码在url远auth。
$file = 'https://user:password@kc.humanitarianresponse.info/media/original?media_file=xxxxx.jpg';
$newfile = 'images.jpg';
if ( copy($file, $newfile) ) {
echo "Copy success!";
}else{
echo "Copy failed.";
}https://stackoverflow.com/questions/67803253
复制相似问题