(sort of bug 32410) Fix EXIF GPSAltitude calculation when below sea level.
authorBrian Wolff <bawolff+wn@gmail.com>
Fri, 17 Aug 2012 00:41:13 +0000 (21:41 -0300)
committerCatrope <roan.kattouw@gmail.com>
Thu, 23 Aug 2012 18:53:14 +0000 (11:53 -0700)
commitd1f0c5a7d8e25d378b06fb0850727a357b6b39f6
treead68391b1dbd527a69c65dbcb7bdd3d64f894677
parentca13fde652e1a1a05c835219af7b014509a1c88f
(sort of bug 32410) Fix EXIF GPSAltitude calculation when below sea level.

In EXIF, GPSAltitude is stored as a fraction string like "1/2".
For values below sea level we were negating this value, in order
to represent the sign and the magnitude in the same value. However,
I forgot to convert that to an integer before negating it. PHP was nice
enough to do a best effort conversion of the string to an integer.
This resulted in altitudes below sea level being taken as just the
numerator of the altitude, which gives results that can be significantly
off.

Also add unit tests for the GPS related image metadata stuff. Change the
existing GPS test to use a fractional altitude (Since this issue isn't
appearent if the denominator is 1). Add tests for XMP as well, since
XMP had same issue, and has to do same processing as EXIF stuff does.

In some future time, may want to consider just converting all exif rational values
to real numbers during the extraction process for generally better sanity.

Patchset 2: rebase

Change-Id: I49032b52a4c840b28e667a6a2b8ae23c508df247
RELEASE-NOTES-1.20
includes/media/Exif.php
includes/media/XMP.php
tests/phpunit/data/media/exif-gps.jpg
tests/phpunit/data/xmp/gps.result.php [new file with mode: 0644]
tests/phpunit/data/xmp/gps.xmp [new file with mode: 0644]
tests/phpunit/includes/media/ExifTest.php
tests/phpunit/includes/media/XMPTest.php