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: -
Votes:10
Avg. Score:4.5 ± 0.5
Reproduced:10 of 10 (100.0%)
Same Version:5 (50.0%)
Same OS:1 (10.0%)
From: tom_kincaid at hotmail dot com Assigned:
Status: Open Package: EXIF related
PHP Version: 5.6.25 OS: Centos 7
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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;
			}
=====
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Apr 25 14:01:39 2017 UTC