php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39617 Erroneously uses the GPS version tag to determine byte order of GPS fields
Submitted: 2006-11-24 13:19 UTC Modified: 2008-11-10 01:00 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: me+php at drbeat dot li Assigned: helly (profile)
Status: No Feedback Package: EXIF related
PHP Version: 5.2.0 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: me+php at drbeat dot li
New email:
PHP Version: OS:

 

 [2006-11-24 13:19 UTC] me+php at drbeat dot li
Description:
------------
When reading GPS EXIF tags, PHP seems to use the GPS version tag to determine the byte order of the other GPS tags instead of the byte order indicator from the EXIF header. An image that shows the incorrect behavior is at http://www.drbeat.li/test/testgps.jpg .

In this picture, the GPS tag version is stored as the bytes [0, 0, 2, 2] instead of as [2, 2, 0, 0]. exif_read_data() consequently returns wrong fractions for latitude, longitude and altitude.

Reproduce code:
---------------
if (($exif = @exif_read_data($file, 0, true)) !== false && $exif['GPS'])
    print_r($exif['GPS']);


Expected result:
----------------
Array
(
    [GPSVersion] => ????
    [GPSLatitudeRef] => N
    [GPSLatitude] => Array
        (
            [0] => 47/1
            [1] => 8/1
            [2] => 96/25
        )
    [GPSLongitudeRef] => E
    [GPSLongitude] => Array
        (
            [0] => 7/1
            [1] => 13/1
            [2] => 60801/1250
        )
    [GPSAltitudeRef] => ?
    [GPSAltitude] => 436/1
)

Actual result:
--------------
Array
(
    [GPSVersion] => ????
    [GPSLatitudeRef] => N
    [GPSLatitude] => Array
        (
            [0] => 196608/3276800
            [1] => 65536/2004877312
            [2] => 57999413/-1526726656
        )
    [GPSLongitudeRef] => E
    [GPSLongitude] => Array
        (
            [0] => 38666275/3080192
            [1] => 65536/524288
            [2] => 65536/6291456
        )
    [GPSAltitudeRef] => ?
    [GPSAltitude] => 1638400/458752
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-24 16:16 UTC] me+php at drbeat dot li
BTW, this image was resized in Apple's iPhoto.
 [2006-11-25 15:34 UTC] helly@php.net
http://www.exif.org/Exif2-2.PDF

A. Tags Relating to GPS
GPSVersionID
Indicates the version of GPSInfoIFD. The version is given as 2.2.0.0. This tag is mandatory when GPSInfo tag is
present. Note that the GPSVersionID tag is written as a different byte than the Exif Version tag.
Tag = 0 (0.H)
Type = BYTE
Count = 4
Default = 2.2.0.0
2.2.0.0 = Version 2.2
Other = reserved

======================================
That is your GPS IFD is corrupted. No matter what the byte order is - the version is always stored in the same order.

To analyze whether t he whole data is corrupted or there is still an error in ext/exif i would need the image.
 [2006-11-25 19:26 UTC] me+php at drbeat dot li
Sorry, wrong link :-(

The picture is at http://www.drbeat.li/test/images/testgps.jpg

Additionally, a correct image is at http://www.drbeat.li/test/images/testgps2.jpg
 [2008-11-02 12:38 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2008-11-10 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 15:01:28 2024 UTC