php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73004 PHP 5.6 Doesn't Read EXIF Location
Submitted: 2016-09-02 14:10 UTC Modified: 2017-08-29 01:15 UTC
Votes:13
Avg. Score:4.3 ± 0.6
Reproduced:12 of 12 (100.0%)
Same Version:6 (50.0%)
Same OS:1 (8.3%)
From: tom_kincaid at hotmail dot com Assigned: kalle (profile)
Status: Closed Package: EXIF related
PHP Version: 5.6.25 OS: Centos 7
Private report: No CVE-ID: None
 [2016-09-02 14:10 UTC] tom_kincaid at hotmail dot com
Description:
------------
exif_read_data on 5.6 doesn't read the EXIF location data. This data is in the photo, but doesn't appear in the response from exif_read_data

    [GPSLatitudeRef] => N
    [GPSLatitude] => Array
        (
            [0] => 40/1
            [1] => 42/1
            [2] => 4941/100
        )

    [GPSLongitudeRef] => W
    [GPSLongitude] => Array
        (
            [0] => 73/1
            [1] => 57/1
            [2] => 2954/100
        )

Here is a sample image with EXIF GPS location:

https://dl.dropboxusercontent.com/u/34732957/test.jpg

Test script:
---------------
$exif = exif_read_data ("/path/to/photo.jpg");
print_r($exif);

Expected result:
----------------
Array
(
    [FileName] => test.jpg
    [FileDateTime] => 1472824820
    [FileSize] => 1406969
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS
    [COMPUTED] => Array
        (
            [html] => width="3264" height="2448"
            [Height] => 2448
            [Width] => 3264
            [IsColor] => 1
            [ByteOrderMotorola] => 1
            [ApertureFNumber] => f/2.2
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
        )

    [Make] => Apple
    [Model] => iPhone 5s
    [Orientation] => 1
    [XResolution] => 72/1
    [YResolution] => 72/1
    [ResolutionUnit] => 2
    [Software] => 9.2
    [DateTime] => 2016:04:10 17:05:26
    [YCbCrPositioning] => 1
    [Exif_IFD_Pointer] => 198
    [GPS_IFD_Pointer] => 1612
    [THUMBNAIL] => Array
        (
            [Compression] => 6
            [XResolution] => 72/1
            [YResolution] => 72/1
            [ResolutionUnit] => 2
            [JPEGInterchangeFormat] => 1952
            [JPEGInterchangeFormatLength] => 9663
        )

    [ExposureTime] => 1/1709
    [FNumber] => 11/5
    [ExposureProgram] => 2
    [ISOSpeedRatings] => 32
    [ExifVersion] => 0221
    [DateTimeOriginal] => 2016:04:10 17:05:26
    [DateTimeDigitized] => 2016:04:10 17:05:26
    [ComponentsConfiguration] => 
    [ShutterSpeedValue] => 19277/1795
    [ApertureValue] => 7983/3509
    [BrightnessValue] => 6632/653
    [ExposureBiasValue] => 0/1
    [MeteringMode] => 5
    [Flash] => 24
    [FocalLength] => 83/20
    [SubjectLocation] => Array
        (
            [0] => 1632
            [1] => 1224
            [2] => 1793
            [3] => 1073
        )

    [MakerNote] => Apple iOS...
    [SubSecTimeOriginal] => 986
    [SubSecTimeDigitized] => 986
    [FlashPixVersion] => 0100
    [ColorSpace] => 1
    [ExifImageWidth] => 3264
    [ExifImageLength] => 2448
    [SensingMethod] => 2
    [SceneType] => 
    [ExposureMode] => 0
    [WhiteBalance] => 0
    [DigitalZoomRatio] => 1224/463
    [FocalLengthIn35mmFilm] => 76
    [SceneCaptureType] => 0
    [UndefinedTag:0xA432] => Array
        (
            [0] => 83/20
            [1] => 83/20
            [2] => 11/5
            [3] => 11/5
        )

    [UndefinedTag:0xA433] => Apple
    [UndefinedTag:0xA434] => iPhone 5s back camera 4.15mm f/2.2
    [GPSLatitudeRef] => N
    [GPSLatitude] => Array
        (
            [0] => 40/1
            [1] => 42/1
            [2] => 4941/100
        )

    [GPSLongitudeRef] => W
    [GPSLongitude] => Array
        (
            [0] => 73/1
            [1] => 57/1
            [2] => 2954/100
        )

    [GPSAltitudeRef] => 
    [GPSAltitude] => 9068/843
    [GPSTimeStamp] => Array
        (
            [0] => 21/1
            [1] => 5/1
            [2] => 2426/100
        )

    [GPSSpeedRef] => K
    [GPSSpeed] => 0/1
    [GPSDateStamp] => 2016:04:10
    [UndefinedTag:0x001F] => 65/1
)


Actual result:
--------------
Array
(
    [FileName] => test.jpg
    [FileDateTime] => 1472776885
    [FileSize] => 1406969
    [FileType] => 2
    [MimeType] => image/jpeg
    [SectionsFound] => ANY_TAG, IFD0, EXIF
    [COMPUTED] => Array
        (
            [html] => width="3264" height="2448"
            [Height] => 2448
            [Width] => 3264
            [IsColor] => 1
            [ByteOrderMotorola] => 1
            [ApertureFNumber] => f/2.2
        )

    [Make] => Apple
    [Model] => iPhone 5s
    [Orientation] => 1
    [XResolution] => 72/1
    [YResolution] => 72/1
    [ResolutionUnit] => 2
    [Software] => 9.2
    [DateTime] => 2016:04:10 17:05:26
    [YCbCrPositioning] => 1
    [ExposureTime] => 1/1709
    [FNumber] => 11/5
    [ExposureProgram] => 2
    [ISOSpeedRatings] => 32
    [ExifVersion] => 0221
    [DateTimeOriginal] => 2016:04:10 17:05:26
    [DateTimeDigitized] => 2016:04:10 17:05:26
    [ComponentsConfiguration] => 
    [ShutterSpeedValue] => 19277/1795
    [ApertureValue] => 7983/3509
    [BrightnessValue] => 6632/653
    [ExposureBiasValue] => 0/1
    [MeteringMode] => 5
    [Flash] => 24
    [FocalLength] => 83/20
    [SubjectLocation] => Array
        (
            [0] => 1632
            [1] => 1224
            [2] => 1793
            [3] => 1073
        )

)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-14 21:23 UTC] dotpointer at gmail dot com
I'm running Debian 8.5 and the Debian (apt-get) supplied version: PHP 5.6.24-0+deb8u1.

I have also this bug - exif_read_data() has stopped outputting GPS tags in my case.

I guess it has todo with the security fix recently applied, noted here:
http://stackoverflow.com/questions/38772471/php-exif-read-data-no-longer-extracts-gps-location

I understand that security fixes are crucial, but don't know how this regression in functionality could have reached production level as I'm running an updated standard Debian installation and not testing. 

GPS reading implementations in PHP are probably breaking all around the planet right now. I hope this will be fixed soon for 5.6+ too.
 [2016-10-16 04:58 UTC] alex at twbsd dot org
Started from 5.6.24, exif can't read GPS location any more. It worked at 5.6.23.
But I tested 5.6.24~5.6.27 and 7.0.12 all won't work.


Test code:

#!/usr/local/bin/php
<?php
$e = exif_read_data("IMG_4017.JPG", 0,true,false);
var_dump($e['GPS']);


Remove the following code in exif.c, the GPS info can be read again:
=====
if (offset_diff < 0 || offset_diff >= value_len ) {
				exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data bad offset: 0x%04X length 0x%04X", offset_diff, value_len);
				return FALSE;
			}
=====
 [2017-06-20 03:57 UTC] kalle@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: kalle
 [2017-07-07 10:31 UTC] kalle@php.net
-Status: Assigned +Status: Feedback
 [2017-07-07 10:31 UTC] kalle@php.net
Hi

Could you please re-upload the image? I believe that a recent bug fix I did to the EXIF extensionn may have fixed this in the process and I need something to verify this.

Thanks!
 [2017-07-16 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2017-08-25 08:11 UTC] xiaolujih at yahoo dot com
I am having this issue: exif_read_data() does not return/extract any GPS location data. I have tried with many valid JPGE image files. 

And my PHP info shows the versions with PHP and with the EXIF function I am using/running:

PHP information: PHP Version 5.2.17 
EXIF Support enabled
EXIF Version 1.4 $Id: exif.c 293036 2010-01-03 09:23:27Z sebastian $
Supported EXIF Version 0220
Supported filetypes JPEG,TIFF

Thanks!
 [2017-08-25 13:48 UTC] kalle@php.net
-Status: No Feedback +Status: Feedback
 [2017-08-25 13:48 UTC] kalle@php.net
Please supply me with any valid images so that I can further debug them. 

Also try PHP 7.2, which includes a large number of fixes to exif
 [2017-08-25 17:35 UTC] alex at twbsd dot org
Here is 2 more files that doesn't work.
http://gofile.me/34nYu/veF3dVpoY
http://gofile.me/34nYu/etLhiFUFH

These pictures are token by using Canon 6D. It has built-in GPS.

You may find other Canon 6D pictures online:
http://web.canon.jp/imaging/eosd/samples/eos6d/downloads/01.jpg
https://www.flickr.com/photos/43728480@N07/11810674583/sizes/o/


Pictures took by iPhone 7 works well though.
Tried on PHP 7.1.8

Thank you for looking into this issue.
 [2017-08-25 17:51 UTC] kalle@php.net
Thanks for providing me with the images, I'll take a look at it Monday, if you can then please check 7.2 where a lot of bugs are fixed. These were not merged as they were a part of a larger group of changes to the extension
 [2017-08-29 01:07 UTC] kalle@php.net
-Status: Feedback +Status: Assigned
 [2017-08-29 01:15 UTC] kalle@php.net
-Status: Assigned +Status: Closed
 [2017-08-29 01:15 UTC] kalle@php.net
I can confirm that this is fixed in PHP 7.2+, as this fix was a part of a larger change set to the exif extension, I doubt it will find its way further down in the branch list.

I apologies for this, but I hope that migrating to PHP 7.2.0 once released won't be too much of a hassle :)

Happy hacking!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC