summaryrefslogtreecommitdiff
path: root/modules/exif
diff options
context:
space:
mode:
Diffstat (limited to 'modules/exif')
-rw-r--r--modules/exif/helpers/exif.php58
-rw-r--r--modules/exif/lib/exif.php38
-rw-r--r--modules/exif/tests/Exif_Test.php2
3 files changed, 39 insertions, 59 deletions
diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php
index 747c3171..b0e7e93f 100644
--- a/modules/exif/helpers/exif.php
+++ b/modules/exif/helpers/exif.php
@@ -104,35 +104,35 @@ class exif_Core {
private static function _keys() {
if (!isset(self::$exif_keys)) {
self::$exif_keys = array(
- "Make" => array("IFD0", "Make", t("Camera Maker"), true),
- "Model" => array("IFD0", "Model", t("Camera Model"), true),
- "Aperture" => array("SubIFD", "FNumber", t("Aperture"), true),
- "ColorSpace" => array("SubIFD", "ColorSpace", t("Color Space"), true),
- "ExposureBias" => array("SubIFD", "ExposureBiasValue", t("Exposure Value"), true),
- "ExposureProgram" => array("SubIFD", "ExposureProgram", t("Exposure Program"), true),
- "ExposureTime" => array("SubIFD", "ExposureTime", t("Exposure Time"), true),
- "Flash" => array("SubIFD", "Flash", t("Flash"), true),
- "FocalLength" => array("SubIFD", "FocalLength", t("Focal Length"), true),
- "ISO" => array("SubIFD", "ISOSpeedRatings", t("ISO"), true),
- "MeteringMode" => array("SubIFD", "MeteringMode", t("Metering Mode"), true),
- "DateTime" => array("SubIFD", "DateTimeOriginal", t("Date/Time"), true),
- "Copyright" => array("IFD0", "Copyright", t("Copyright"), false),
- "ImageType" => array("IFD0", "ImageType", t("Image Type"), false),
- "Orientation" => array("IFD0", "Orientation", t("Orientation"), false),
- "ResolutionUnit" => array("IFD0", "ResolutionUnit", t("Resolution Unit"), false),
- "xResolution" => array("IFD0", "xResolution", t("X Resolution"), false),
- "yResolution" => array("IFD0", "yResolution", t("Y Resolution"), false),
- "Compression" => array("IFD1", "Compression", t("Compression"), false),
- "BrightnessValue" => array("SubIFD", "BrightnessValue", t("Brightness Value"), false),
- "Contrast" => array("SubIFD", "Contrast", t("Contrast"), false),
- "ExposureMode" => array("SubIFD", "ExposureMode", t("Exposure Mode"), false),
- "FlashEnergy" => array("SubIFD", "FlashEnergy", t("Flash Energy"), false),
- "Saturation" => array("SubIFD", "Saturation", t("Saturation"), false),
- "SceneType" => array("SubIFD", "SceneType", t("Scene Type"), false),
- "Sharpness" => array("SubIFD", "Sharpness", t("Sharpness"), false),
- "SubjectDistance" => array("SubIFD", "SubjectDistance", t("Subject Distance"), false),
- "Caption" => array("IPTC", "Caption", t("Caption"), false),
- "Keywords" => array("IPTC", "Keywords", t("Keywords"), false)
+ "Make" => array("IFD0", "Make", t("Camera Maker"), ),
+ "Model" => array("IFD0", "Model", t("Camera Model"), ),
+ "Aperture" => array("SubIFD", "FNumber", t("Aperture"), ),
+ "ColorSpace" => array("SubIFD", "ColorSpace", t("Color Space"), ),
+ "ExposureBias" => array("SubIFD", "ExposureBiasValue", t("Exposure Value"), ),
+ "ExposureProgram" => array("SubIFD", "ExposureProgram", t("Exposure Program"), ),
+ "ExposureTime" => array("SubIFD", "ExposureTime", t("Exposure Time"), ),
+ "Flash" => array("SubIFD", "Flash", t("Flash"), ),
+ "FocalLength" => array("SubIFD", "FocalLength", t("Focal Length"), ),
+ "ISO" => array("SubIFD", "ISOSpeedRatings", t("ISO"), ),
+ "MeteringMode" => array("SubIFD", "MeteringMode", t("Metering Mode"), ),
+ "DateTime" => array("SubIFD", "DateTimeOriginal", t("Date/Time"), ),
+ "Copyright" => array("IFD0", "Copyright", t("Copyright"), ),
+ "ImageType" => array("IFD0", "ImageType", t("Image Type"), ),
+ "Orientation" => array("IFD0", "Orientation", t("Orientation"), ),
+ "ResolutionUnit" => array("IFD0", "ResolutionUnit", t("Resolution Unit"), ),
+ "xResolution" => array("IFD0", "xResolution", t("X Resolution"), ),
+ "yResolution" => array("IFD0", "yResolution", t("Y Resolution"), ),
+ "Compression" => array("IFD1", "Compression", t("Compression"), ),
+ "BrightnessValue" => array("SubIFD", "BrightnessValue", t("Brightness Value"), ),
+ "Contrast" => array("SubIFD", "Contrast", t("Contrast"), ),
+ "ExposureMode" => array("SubIFD", "ExposureMode", t("Exposure Mode"), ),
+ "FlashEnergy" => array("SubIFD", "FlashEnergy", t("Flash Energy"), ),
+ "Saturation" => array("SubIFD", "Saturation", t("Saturation"), ),
+ "SceneType" => array("SubIFD", "SceneType", t("Scene Type"), ),
+ "Sharpness" => array("SubIFD", "Sharpness", t("Sharpness"), ),
+ "SubjectDistance" => array("SubIFD", "SubjectDistance", t("Subject Distance"), ),
+ "Caption" => array("IPTC", "Caption", t("Caption"), ),
+ "Keywords" => array("IPTC", "Keywords", t("Keywords"), )
);
}
return self::$exif_keys;
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
}
}
diff --git a/modules/exif/tests/Exif_Test.php b/modules/exif/tests/Exif_Test.php
index 312ed535..5c5a5cb1 100644
--- a/modules/exif/tests/Exif_Test.php
+++ b/modules/exif/tests/Exif_Test.php
@@ -31,11 +31,11 @@ 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" => "1/60 sec"),
array("caption" => "Flash", "value" => "No Flash"),
array("caption" => "Focal Length", "value" => "50 mm"),
array("caption" => "ISO", "value" => "6553700"),
array("caption" => "Metering Mode", "value" => "Multi-Segment"),
- array("caption" => "Shutter Speed", "value" => "1/60 sec"),
array("caption" => "Date/Time", "value" => "2008:03:17 17:41:25"),
array("caption" => "Copyright", "value" => "(C) 2008 - T. Almdal"),
array("caption" => "Orientation", "value" => "1: Normal (0 deg)"),