|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [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
        )
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 17:00:02 2025 UTC | 
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; } =====