PHP exif_read_data不再提取GPS位置 [英] PHP exif_read_data no longer extracts GPS location

查看:414
本文介绍了PHP exif_read_data不再提取GPS位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚通过自制软件安装了composer,并且brew似乎安装了新版本的php(5.6.24)。此后,使用exif_read_data提取其他元数据(模型,曝光,iso等),但不再从照片中提取诸如GPSLatitude之类的GPS信息。



照片通过exiftool(独立的非PHP程序)和GPS数据确实存在照片中。



PHP是用exif编译的(因为有些信息被拖拽) m搔痒我的头为什么GPS数据不再被读取。

解决方案

这很可能是由于安全修复这导致ext / exif扩展在未知格式的情况下停止解析。



这应该在7.x分支中解决(7.0.10和7.1.0 Beta 1)应该包含适当的修正,尽管它没有合并到5.x分支,但它可能会在那里找到它。



如果你需要一个补丁(这应该很容易转换成5.x),然后我在这里提交它:
http://git.php.net/?p=php-src.git;a=commit;h=aabcb5481d9e717df77192dab2894468b9fc63b4



在内部,当我们解析exif数据时,它会读出标准的exif标签如规范所提供的那样,但是某些格式具有特定的自定义标签。这些通常也被解析,但是ext / exif仅限于我们(在包括7.1的稳定分支中)支持具有扩展标记的6种格式(每种格式的列表被烘焙到扩展中),这是有限的。这是回归的地方。解析EXIF数据时,按以下顺序完成:


  • 标准EXIF数据
  • >
  • 查找已知的解析自定义标签的格式,如果找到匹配的签名,然后解析它们解析附加数据,如缩略图,GPS等
  • >


安全修复程序导致了回归,因为您可以制作假签名并在内部绕过该内容,从而导致无效读取。如果签名在我们知道的格式的签名列表中出现签名不匹配的情况,修复程序会保留解析,从而停止解析并且不返回缩略图之类的数据,导致exif_t​​humbnail()基本上不可用于除6



目前在7.x分支中修复,恢复了这种行为并简单地继续解析这些附加标签,所以这些功能和其他格式我们不直接支持,除此之外,在7.2版本中,我一直在增加对三星,松下和DJI特定标签的支持,目前我正在研究索尼特定数据也。我们在php.net上有一个错误报告,当你有兴趣更深入地查看这个消息时,它会将它全部闪烁: https://bugs.php.net/bug.php?id=72735 。如果这个补丁没有解决您的问题,欢迎您提交错误报告,以便我们研究解决此问题。



我希望这对您有所帮助,并感谢帮助使PHP更加伟大!


I just installed composer via homebrew and brew seemed to install a new version of php (5.6.24). Since then, using exif_read_data extracts other metadata (model, exposure, iso, etc), but no longer extracts GPS info like "GPSLatitude" from photos.

I ran the same photo through exiftool (standalone non-php program) and GPS data does exist in the photo.

PHP is compiled with exif (as some info is pulled), so I'm scratching my head why GPS data is no longer being read.

解决方案

This is most likely due to a regression from a security fix that was causing the ext/exif extension to stop parsing in case of an "unknown" format.

This should be fixed in the 7.x branches (7.0.10 and 7.1.0 Beta 1) should contain a proper fix for these, although it was not merged to the 5.x branches, it could likely find its way there.

If you want a patch (which should be fairly easy to convert into 5.x), then I committed it here: http://git.php.net/?p=php-src.git;a=commit;h=aabcb5481d9e717df77192dab2894468b9fc63b4

Here is a little background on how ext/exif works and what went wrong:

Internally when we parse the exif data, it will read out the standard exif tags as provided by the spec, however certain formats, have certain custom tags. These are usually parsed too, however ext/exif is limited in the sense that we only (in stable branches including 7.1) support 6 formats with extended tags (the list for each format is baked into the extension). This is where the regression comes in. When parsing the EXIF data, it is done in the following order:

  • Standard EXIF data
  • Look for known formats for parsing custom tags, if a matching signature is found, then parse them
  • Parse additional data, like thumbnail, GPS etc

The security fix caused a regression, because you could craft fake signatures and bypass this internally, which could cause invalid reads. The fix would then bail the parsing in case of a signature mismatch in the list of baked in signatures from formats we know, thus stopping to parse and not returning data like thumbnails, causing exif_thumbnail() to essentially not be usable for any but the 6 formats.

The fix currently in the 7.x branches, restores this behavior and simply continues to parse those additional tags, so those functions and other formats we do not directly support, will once again work.

Besides that, in 7.2, I have been adding support for Samsung, Panasonic and DJI specific tags, and I'm currently looking into Sony specific data too. We have a bug report at php.net which sparkled it all in case you are interested in looking more in depth with this: https://bugs.php.net/bug.php?id=72735. And should this patch not fix your issue, you are more than welcome to submit a bug report so we can look into resolving this.

I hope this was helpful to you, and thanks for helping to make PHP even greater!

这篇关于PHP exif_read_data不再提取GPS位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆