summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-07-01 11:32:27 -0700
committerBharat Mediratta <bharat@menalto.com>2009-07-01 11:32:27 -0700
commit7b1e3c50218b235a7d25ebe21f93eb8dd9acfb84 (patch)
treefb3ac6f3c232f7bc03af50071c60487cd0f31afa
parent8f4c1c4ddf8473fbe401c2f8682ab1d69975eb6f (diff)
Reapply c65bfb5a10b125b2cf04ebd5c5d1b58051281f8c without extra
whitespace changes.
-rw-r--r--modules/exif/lib/exif.php32
-rw-r--r--modules/exif/tests/Exif_Test.php2
2 files changed, 3 insertions, 31 deletions
diff --git a/modules/exif/lib/exif.php b/modules/exif/lib/exif.php
index f335dad4..21b028f8 100644
--- a/modules/exif/lib/exif.php
+++ b/modules/exif/lib/exif.php
@@ -1007,36 +1007,8 @@ if ($result['ValidJpeg'] == 1) {
//================================================================================================
function ConvertToFraction($v, &$n, &$d)
{
- $MaxTerms = 15; // Limit to prevent infinite loop
- $MinDivisor = 0.000001; // Limit to prevent divide by zero
- $MaxError = 0.00000001; // How close is enough
-
- $f = $v; // Initialize fraction being converted
-
- $n_un = 1; // Initialize fractions with 1/0, 0/1
- $d_un = 0;
- $n_deux = 0;
- $d_deux = 1;
-
- for ($i = 0; $i<$MaxTerms; $i++)
- {
- $a = floor($f); // Get next term
- $f = $f - $a; // Get new divisor
- $n = $n_un * $a + $n_deux; // Calculate new fraction
- $d = $d_un * $a + $d_deux;
- $n_deux = $n_un; // Save last two fractions
- $d_deux = $d_un;
- $n_un = $n;
- $d_un = $d;
-
- if ($f < $MinDivisor) // Quit if dividing by zero
- break;
-
- if (abs($v - $n / $d) < $MaxError)
- break;
-
- $f = 1 / $f; // Take reciprocal
- }
+ $n = 1;
+ $d = !empty($v) ? round(1.0 / $v) : 0;
}
//================================================================================================
diff --git a/modules/exif/tests/Exif_Test.php b/modules/exif/tests/Exif_Test.php
index f94d0357..5c5a5cb1 100644
--- a/modules/exif/tests/Exif_Test.php
+++ b/modules/exif/tests/Exif_Test.php
@@ -31,7 +31,7 @@ class Exif_Test extends Unit_Test_Case {
array("caption" => "Color Space", "value" => "Uncalibrated"),
array("caption" => "Exposure Value", "value" => "4294.67 EV"),
array("caption" => "Exposure Program", "value" => "Program"),
- array("caption" => "Exposure Time", "value" => "833/49979 sec"),
+ array("caption" => "Exposure Time", "value" => "1/60 sec"),
array("caption" => "Flash", "value" => "No Flash"),
array("caption" => "Focal Length", "value" => "50 mm"),
array("caption" => "ISO", "value" => "6553700"),