* No longer displaying ResolutionUnit at all
[lhc/web/wiklou.git] / includes / Exif.php
index 1bd4687..7e90175 100644 (file)
@@ -84,6 +84,8 @@ class Exif {
 
        /**
         * Constructor
+        *
+        * @param string $file
         */
        function Exif( $file ) {
                /**
@@ -305,8 +307,6 @@ class Exif {
                }
        }
        
-       /**#@-*/
-       
        /**
         * Make $this->mFilteredExifData
         */
@@ -377,7 +377,9 @@ class Exif {
 
        /**#@+
         * Validates if a tag value is of the type it should be according to the Exif spec
-        * 
+        *
+        * @access private
+        *
         * @param mixed $in The input value to check
         * @return bool
         */
@@ -472,6 +474,8 @@ class Exif {
        /**
         * Validates if a tag has a legal value according to the Exif spec
         *
+        * @access private
+        *
         * @param string $tag The tag to check
         * @param mixed  $val The value of the tag
         * @return bool
@@ -516,6 +520,8 @@ class Exif {
        /**
         * Conviniance function for debugging output
         *
+        * @access private
+        *
         * @param mixed $in 
         * @param string $fname
         * @param mixed $action
@@ -573,6 +579,9 @@ class FormatExif {
                global $wgLang;
                
                $tags =& $this->mExif;
+
+               $resolutionunit = !isset( $tags['ResolutionUnit'] ) || $tags['ResolutionUnit'] == 2 ? 2 : 3;
+               unset( $tags['ResolutionUnit'] );
                
                foreach( $tags as $tag => $val ) {
                        switch( $tag ) {
@@ -622,18 +631,22 @@ class FormatExif {
                        
                        // TODO: YCbCrSubSampling
                        // TODO: YCbCrPositioning
-                       // TODO: If this field does not exists use 2
-                       case 'ResolutionUnit': #p26
-                               switch( $val ) {
-                               case 2: case 3:
-                                       $tags[$tag] = $this->msg( $tag, $val );
-                                       break;
-                               default:
-                                       $tags[$tag] = $val;
-                                       break;
+                       
+                       case 'XResolution':
+                       case 'YResolution':
+                               switch( $resolutionunit ) {
+                                       case 2:
+                                               $tags[$tag] = $this->msg( 'XYResolution', 'i', $this->formatNum( $val ) );
+                                               break;
+                                       case 3:
+                                               $this->msg( 'XYResolution', 'c', $this->formatNum( $val ) );
+                                               break;
+                                       default:
+                                               $tags[$tag] = $val;
+                                               break;
                                }
                                break;
-                       
+                               
                        // TODO: YCbCrCoefficients  #p27 (see annex E)
                        case 'ExifVersion': case 'FlashpixVersion':
                                $tags[$tag] = "$val"/100;
@@ -945,18 +958,25 @@ class FormatExif {
        /**
         * Conviniance function for getFormattedData()
         *
+        * @access private
+        *
         * @param string $tag The tag name to pass on
         * @param string $val The value of the tag
         * @param string $arg An argument to pass ($1)
         * @return string A wfMsg of "exif-$tag-$val" in lower case
         */
        function msg( $tag, $val, $arg = null ) {
-               if ($val == '')
+               if ($val === '')
                        $val = 'value';
                return wfMsg( strtolower( "exif-$tag-$val" ), $arg );
        }
 
        /**
+        * Format a number, convert numbers from fractions into floating point
+        * numbers
+        *
+        * @access private
+        *
         * @param mixed $num The value to format
         * @return mixed A floating point number or whatever we were fed
         */