/**
* Constructor
+ *
+ * @param string $file
*/
function Exif( $file ) {
/**
}
}
- /**#@-*/
-
/**
* Make $this->mFilteredExifData
*/
/**#@+
* 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
*/
/**
* 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
/**
* Conviniance function for debugging output
*
+ * @access private
+ *
* @param mixed $in
* @param string $fname
* @param mixed $action
global $wgLang;
$tags =& $this->mExif;
+
+ $resolutionunit = !isset( $tags['ResolutionUnit'] ) || $tags['ResolutionUnit'] == 2 ? 2 : 3;
+ unset( $tags['ResolutionUnit'] );
foreach( $tags as $tag => $val ) {
switch( $tag ) {
// 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;
break;
}
break;
+
+ case 'SubjectDistance':
+ $tags[$tag] = $this->msg( $tag, '', $this->formatNum( $val ) );
+ break;
case 'MeteringMode':
switch( $val ) {
case 'Make':
case 'Model':
case 'Software':
- $tags[$tag] = wfMsg( strtolower( "exif-$tag-value" ), $val );
+ $tags[$tag] = $this->msg( $tag, '', $val );
break;
default:
- if ( preg_match( '/^(\d+)\/(\d+)$/', $val, $m ) ) {
- $tags[$tag] = $m[2] != 0 ? $m[1]/$m[2] : $val;
- break;
- }
- $tags[$tag] = $val;
+ $tags[$tag] = $this->formatNum( $val );
break;
}
}
}
/**
- * Conviniance function for format()
+ * 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 ) {
- return wfMsg( strtolower("exif-$tag-$val") );
+ function msg( $tag, $val, $arg = null ) {
+ 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
+ */
+ function formatNum( $num ) {
+ if ( preg_match( '/^(\d+)\/(\d+)$/', $num, $m ) )
+ return $m[2] != 0 ? $m[1] / $m[2] : $num;
+ else
+ return $num;
}
}