diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-07-02 18:00:22 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-07-02 18:00:22 -0700 |
commit | eb5538d1357dade9e6e08d1b603033928944011c (patch) | |
tree | ee04f9be38a40f4125eafab5367bba6cf1b61164 /modules/exif/lib | |
parent | 1a5fe42b555d51d22bde1521100a31d2b434486b (diff) | |
parent | a633c134b754305eaa611c5d67af4ca7c79beafe (diff) |
Merge branch 'master' of git@github.com:/gallery/gallery3
Conflicts:
modules/server_add/controllers/admin_server_add.php
Diffstat (limited to 'modules/exif/lib')
-rw-r--r-- | modules/exif/lib/exif.php | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/modules/exif/lib/exif.php b/modules/exif/lib/exif.php index f335dad4..bd72f237 100644 --- a/modules/exif/lib/exif.php +++ b/modules/exif/lib/exif.php @@ -1007,35 +1007,15 @@ 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 + if ($v == 0) { + $n = 0; + $d = 1; + return; + } + for ($n=1; $n<100; $n++) { + $v1 = 1/$v*$n; + $d = round($v1, 0); + if (abs($d - $v1) < 0.02) return;// within tolarance } } |