2 if ( !defined( 'MEDIAWIKI' ) ) die();
7 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
8 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
9 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * http://www.gnu.org/copyleft/gpl.html
26 * @link http://exif.org/Exif2-2.PDF The Exif 2.2 specification
31 * Exif tag type definition
33 define('MW_EXIF_BYTE', 1); # An 8-bit unsigned integer.
34 define('MW_EXIF_ASCII', 2); # An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL.
35 define('MW_EXIF_SHORT', 3); # A 16-bit (2-byte) unsigned integer.
36 define('MW_EXIF_LONG', 4); # A 32-bit (4-byte) unsigned integer.
37 define('MW_EXIF_RATIONAL', 5); # Two LONGs. The first LONG is the numerator and the second LONG expresses the denominator
38 define('MW_EXIF_UNDEFINED', 7); # An 8-bit byte that can take any value depending on the field definition
39 define('MW_EXIF_SLONG', 9); # A 32-bit (4-byte) signed integer (2's complement notation),
40 define('MW_EXIF_SRATIONAL', 10); # Two SLONGs. The first SLONG is the numerator and the second SLONG is the denominator.
46 * @subpackage Metadata
55 * Exif tags grouped by category, the tagname itself is the key and the type
56 * is the value, in the case of more than one possible value type they are
57 * seperated by commas.
62 * A one dimentional array of all Exif tags
67 * The raw Exif data returned by exif_read_data()
72 * A Filtered version of $mRawExifData that has been pruned of invalid
73 * tags and tags that contain content they shouldn't contain according
74 * to the Exif specification
76 var $mFilteredExifData;
79 * Filtered and formatted Exif data, see FormatExif::getFormattedData()
81 var $mFormattedExifData;
88 function Exif( $file ) {
90 * Page numbers here refer to pages in the EXIF 2.2 standard
92 * @link http://exif.org/Exif2-2.PDF The Exif 2.2 specification
94 $this->mExifTags
= array(
95 # TIFF Rev. 6.0 Attribute Information (p22)
97 # Tags relating to image structure
99 'ImageWidth' => MW_EXIF_SHORT
.','.MW_EXIF_LONG
, # Image width
100 'ImageLength' => MW_EXIF_SHORT
.','.MW_EXIF_LONG
, # Image height
101 'BitsPerSample' => MW_EXIF_SHORT
, # Number of bits per component
102 # "When a primary image is JPEG compressed, this designation is not"
103 # "necessary and is omitted." (p23)
104 'Compression' => MW_EXIF_SHORT
, # Compression scheme #p23
105 'PhotometricInterpretation' => MW_EXIF_SHORT
, # Pixel composition #p23
106 'Orientation' => MW_EXIF_SHORT
, # Orientation of image #p24
107 'SamplesPerPixel' => MW_EXIF_SHORT
, # Number of components
108 'PlanarConfiguration' => MW_EXIF_SHORT
, # Image data arrangement #p24
109 'YCbCrSubSampling' => MW_EXIF_SHORT
, # Subsampling ratio of Y to C #p24
110 'YCbCrPositioning' => MW_EXIF_SHORT
, # Y and C positioning #p24-25
111 'XResolution' => MW_EXIF_RATIONAL
, # Image resolution in width direction
112 'YResolution' => MW_EXIF_RATIONAL
, # Image resolution in height direction
113 'ResolutionUnit' => MW_EXIF_SHORT
, # Unit of X and Y resolution #(p26)
116 # Tags relating to recording offset
118 'StripOffsets' => MW_EXIF_SHORT
.','.MW_EXIF_LONG
, # Image data location
119 'RowsPerStrip' => MW_EXIF_SHORT
.','.MW_EXIF_LONG
, # Number of rows per strip
120 'StripByteCounts' => MW_EXIF_SHORT
.','.MW_EXIF_LONG
, # Bytes per compressed strip
121 'JPEGInterchangeFormat' => MW_EXIF_SHORT
.','.MW_EXIF_LONG
, # Offset to JPEG SOI
122 'JPEGInterchangeFormatLength' => MW_EXIF_SHORT
.','.MW_EXIF_LONG
, # Bytes of JPEG data
125 # Tags relating to image data characteristics
126 'characteristics' => array(
127 'TransferFunction' => MW_EXIF_SHORT
, # Transfer function
128 'WhitePoint' => MW_EXIF_RATIONAL
, # White point chromaticity
129 'PrimaryChromaticities' => MW_EXIF_RATIONAL
, # Chromaticities of primarities
130 'YCbCrCoefficients' => MW_EXIF_RATIONAL
, # Color space transformation matrix coefficients #p27
131 'ReferenceBlackWhite' => MW_EXIF_RATIONAL
# Pair of black and white reference values
136 'DateTime' => MW_EXIF_ASCII
, # File change date and time
137 'ImageDescription' => MW_EXIF_ASCII
, # Image title
138 'Make' => MW_EXIF_ASCII
, # Image input equipment manufacturer
139 'Model' => MW_EXIF_ASCII
, # Image input equipment model
140 'Software' => MW_EXIF_ASCII
, # Software used
141 'Artist' => MW_EXIF_ASCII
, # Person who created the image
142 'Copyright' => MW_EXIF_ASCII
, # Copyright holder
146 # Exif IFD Attribute Information (p30-31)
148 # Tags relating to version
150 # TODO: NOTE: Nonexistence of this field is taken to mean nonconformance
151 # to the EXIF 2.1 AND 2.2 standards
152 'ExifVersion' => MW_EXIF_UNDEFINED
, # Exif version
153 'FlashpixVersion' => MW_EXIF_UNDEFINED
, # Supported Flashpix version #p32
156 # Tags relating to Image Data Characteristics
157 'characteristics' => array(
158 'ColorSpace' => MW_EXIF_SHORT
, # Color space information #p32
161 # Tags relating to image configuration
162 'configuration' => array(
163 'ComponentsConfiguration' => MW_EXIF_UNDEFINED
, # Meaning of each component #p33
164 'CompressedBitsPerPixel' => MW_EXIF_RATIONAL
, # Image compression mode
165 'PixelYDimension' => MW_EXIF_SHORT
.','.MW_EXIF_LONG
, # Valid image width
166 'PixelXDimension' => MW_EXIF_SHORT
.','.MW_EXIF_LONG
, # Valind image height
169 # Tags relating to related user information
171 'MakerNote' => MW_EXIF_UNDEFINED
, # Manufacturer notes
172 'UserComment' => MW_EXIF_UNDEFINED
, # User comments #p34
175 # Tags relating to related file information
177 'RelatedSoundFile' => MW_EXIF_ASCII
, # Related audio file
180 # Tags relating to date and time
181 'dateandtime' => array(
182 'DateTimeOriginal' => MW_EXIF_ASCII
, # Date and time of original data generation #p36
183 'DateTimeDigitized' => MW_EXIF_ASCII
, # Date and time of original data generation
184 'SubSecTime' => MW_EXIF_ASCII
, # DateTime subseconds
185 'SubSecTimeOriginal' => MW_EXIF_ASCII
, # DateTimeOriginal subseconds
186 'SubSecTimeDigitized' => MW_EXIF_ASCII
, # DateTimeDigitized subseconds
189 # Tags relating to picture-taking conditions (p31)
190 'conditions' => array(
191 'ExposureTime' => MW_EXIF_RATIONAL
, # Exposure time
192 'FNumber' => MW_EXIF_RATIONAL
, # F Number
193 'ExposureProgram' => MW_EXIF_SHORT
, # Exposure Program #p38
194 'SpectralSensitivity' => MW_EXIF_ASCII
, # Spectral sensitivity
195 'ISOSpeedRatings' => MW_EXIF_SHORT
, # ISO speed rating
196 'OECF' => MW_EXIF_UNDEFINED
, # Optoelectronic conversion factor
197 'ShutterSpeedValue' => MW_EXIF_SRATIONAL
, # Shutter speed
198 'ApertureValue' => MW_EXIF_RATIONAL
, # Aperture
199 'BrightnessValue' => MW_EXIF_SRATIONAL
, # Brightness
200 'ExposureBiasValue' => MW_EXIF_SRATIONAL
, # Exposure bias
201 'MaxApertureValue' => MW_EXIF_RATIONAL
, # Maximum land aperture
202 'SubjectDistance' => MW_EXIF_RATIONAL
, # Subject distance
203 'MeteringMode' => MW_EXIF_SHORT
, # Metering mode #p40
204 'LightSource' => MW_EXIF_SHORT
, # Light source #p40-41
205 'Flash' => MW_EXIF_SHORT
, # Flash #p41-42
206 'FocalLength' => MW_EXIF_RATIONAL
, # Lens focal length
207 'SubjectArea' => MW_EXIF_SHORT
, # Subject area
208 'FlashEnergy' => MW_EXIF_RATIONAL
, # Flash energy
209 'SpatialFrequencyResponse' => MW_EXIF_UNDEFINED
, # Spatial frequency response
210 'FocalPlaneXResolution' => MW_EXIF_RATIONAL
, # Focal plane X resolution
211 'FocalPlaneYResolution' => MW_EXIF_RATIONAL
, # Focal plane Y resolution
212 'FocalPlaneResolutionUnit' => MW_EXIF_SHORT
, # Focal plane resolution unit #p46
213 'SubjectLocation' => MW_EXIF_SHORT
, # Subject location
214 'ExposureIndex' => MW_EXIF_RATIONAL
, # Exposure index
215 'SensingMethod' => MW_EXIF_SHORT
, # Sensing method #p46
216 'FileSource' => MW_EXIF_UNDEFINED
, # File source #p47
217 'SceneType' => MW_EXIF_UNDEFINED
, # Scene type #p47
218 'CFAPattern' => MW_EXIF_UNDEFINED
, # CFA pattern
219 'CustomRendered' => MW_EXIF_SHORT
, # Custom image processing #p48
220 'ExposureMode' => MW_EXIF_SHORT
, # Exposure mode #p48
221 'WhiteBalance' => MW_EXIF_SHORT
, # White Balance #p49
222 'DigitalZoomRatio' => MW_EXIF_RATIONAL
, # Digital zoom ration
223 'FocalLengthIn35mmFilm' => MW_EXIF_SHORT
, # Focal length in 35 mm film
224 'SceneCaptureType' => MW_EXIF_SHORT
, # Scene capture type #p49
225 'GainControl' => MW_EXIF_RATIONAL
, # Scene control #p49-50
226 'Contrast' => MW_EXIF_SHORT
, # Contrast #p50
227 'Saturation' => MW_EXIF_SHORT
, # Saturation #p50
228 'Sharpness' => MW_EXIF_SHORT
, # Sharpness #p50
229 'DeviceSettingDescription' => MW_EXIF_UNDEFINED
, # Desice settings description
230 'SubjectDistanceRange' => MW_EXIF_SHORT
, # Subject distance range #p51
234 'ImageUniqueID' => MW_EXIF_ASCII
, # Unique image ID
238 # GPS Attribute Information (p52)
240 'GPSVersionID' => MW_EXIF_BYTE
, # GPS tag version
241 'GPSLatitudeRef' => MW_EXIF_ASCII
, # North or South Latitude #p52-53
242 'GPSLatitude' => MW_EXIF_RATIONAL
, # Latitude
243 'GPSLongitudeRef' => MW_EXIF_ASCII
, # East or West Longitude #p53
244 'GPSLongitude' => MW_EXIF_RATIONAL
, # Longitude
245 'GPSAltitudeRef' => MW_EXIF_BYTE
, # Altitude reference
246 'GPSAltitude' => MW_EXIF_RATIONAL
, # Altitude
247 'GPSTimeStamp' => MW_EXIF_RATIONAL
, # GPS time (atomic clock)
248 'GPSSatellites' => MW_EXIF_ASCII
, # Satellites used for measurement
249 'GPSStatus' => MW_EXIF_ASCII
, # Receiver status #p54
250 'GPSMeasureMode' => MW_EXIF_ASCII
, # Measurement mode #p54-55
251 'GPSDOP' => MW_EXIF_RATIONAL
, # Measurement precision
252 'GPSSpeedRef' => MW_EXIF_ASCII
, # Speed unit #p55
253 'GPSSpeed' => MW_EXIF_RATIONAL
, # Speed of GPS receiver
254 'GPSTrackRef' => MW_EXIF_ASCII
, # Reference for direction of movement #p55
255 'GPSTrack' => MW_EXIF_RATIONAL
, # Direction of movement
256 'GPSImgDirectionRef' => MW_EXIF_ASCII
, # Reference for direction of image #p56
257 'GPSImgDirection' => MW_EXIF_RATIONAL
, # Direction of image
258 'GPSMapDatum' => MW_EXIF_ASCII
, # Geodetic survey data used
259 'GPSDestLatitudeRef' => MW_EXIF_ASCII
, # Reference for latitude of destination #p56
260 'GPSDestLatitude' => MW_EXIF_RATIONAL
, # Latitude destination
261 'GPSDestLongitudeRef' => MW_EXIF_ASCII
, # Reference for longitude of destination #p57
262 'GPSDestLongitude' => MW_EXIF_RATIONAL
, # Longitude of destination
263 'GPSDestBearingRef' => MW_EXIF_ASCII
, # Reference for bearing of destination #p57
264 'GPSDestBearing' => MW_EXIF_RATIONAL
, # Bearing of destination
265 'GPSDestDistanceRef' => MW_EXIF_ASCII
, # Reference for distance to destination #p57-58
266 'GPSDestDistance' => MW_EXIF_RATIONAL
, # Distance to destination
267 'GPSProcessingMethod' => MW_EXIF_UNDEFINED
, # Name of GPS processing method
268 'GPSAreaInformation' => MW_EXIF_UNDEFINED
, # Name of GPS area
269 'GPSDateStamp' => MW_EXIF_ASCII
, # GPS date
270 'GPSDifferential' => MW_EXIF_SHORT
, # GPS differential correction
274 $this->makeFlatExifTags();
275 wfSuppressWarnings();
276 $this->mRawExifData
= exif_read_data( $file );
278 $this->makeFilteredData();
279 $this->makeFormattedData();
286 * Generate a flat list of the exif tags
288 function makeFlatExifTags() {
289 $this->extractTags( $this->mExifTags
);
293 * A recursing extractor function used by makeFlatExifTags()
295 * Note: This used to use an array_walk function, but it made PHP5
296 * segfault, see `cvs diff -u -r 1.4 -r 1.5 Exif.php`
298 function extractTags( &$tagset ) {
299 foreach( $tagset as $key => $val ) {
300 if( is_array( $val ) ) {
301 $this->extractTags( $val );
303 $this->mFlatExifTags
[$key] = $val;
311 * Make $this->mFilteredExifData
313 function makeFilteredData() {
314 $this->mFilteredExifData
= $this->mRawExifData
;
316 foreach( $this->mFilteredExifData
as $k => $v ) {
317 if ( !in_array( $k, array_keys( $this->mFlatExifTags
) ) ) {
318 $this->debug( $v, __FUNCTION__
, "'$k' is not a valid Exif tag" );
319 unset( $this->mFilteredExifData
[$k] );
323 foreach( $this->mFilteredExifData
as $k => $v ) {
324 if ( !$this->validate($k, $v) ) {
325 $this->debug( $v, __FUNCTION__
, "'$k' contained invalid data" );
326 unset( $this->mFilteredExifData
[$k] );
331 function makeFormattedData( $data = null ) {
332 $format = new FormatExif( $this->getFilteredData() );
333 $this->mFormattedExifData
= $format->getFormattedData();
341 * Get $this->mRawExifData
344 return $this->mRawExifData
;
348 * Get $this->mFilteredExifData
350 function getFilteredData() {
351 return $this->mFilteredExifData
;
355 * Get $this->mFormattedExifData
357 function getFormattedData() {
358 return $this->mFormattedExifData
;
363 * The version of the output format
365 * Before the actual metadata information is saved in the database we
366 * strip some of it since we don't want to save things like thumbnails
367 * which usually accompany Exif data. This value gets saved in the
368 * database along with the actual Exif data, and if the version in the
369 * database doesn't equal the value returned by this function the Exif
370 * data is regenerated.
375 return 1; // We don't need no bloddy constants!
379 * Validates if a tag value is of the type it should be according to the Exif spec
381 * @param mixed $in The input value to check
384 function isByte( $in ) {
385 if ( sprintf('%d', $in) == $in && $in >= 0 && $in <= 255 ) {
386 $this->debug( $in, __FUNCTION__
, true );
389 $this->debug( $in, __FUNCTION__
, false );
394 function isASCII( $in ) {
395 if ( preg_match( "/[^\x0a\x20-\x7e]/", $in ) ) {
396 $this->debug( $in, __FUNCTION__
, 'found a character not in our whitelist' );
400 if ( preg_match( "/^\s*$/", $in ) ) {
401 $this->debug( $in, __FUNCTION__
, 'input consisted solely of whitespace' );
405 if ( strlen($in) > 1024 ) { // TODO: This might not be according to the spec
406 $this->debug( $in, __FUNCTION__
, 'input was too long' );
413 function isShort( $in ) {
414 if ( sprintf('%d', $in) == $in && $in >= 0 && $in <= 65536 ) {
415 $this->debug( $in, __FUNCTION__
, true );
418 $this->debug( $in, __FUNCTION__
, false );
423 function isLong( $in ) {
424 if ( sprintf('%d', $in) == $in && $in >= 0 && $in <= 4294967296 ) {
425 $this->debug( $in, __FUNCTION__
, true );
428 $this->debug( $in, __FUNCTION__
, false );
433 function isRational( $in ) {
434 if ( @preg_match
( "/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/", $in, $m ) ) { # Avoid division by zero
435 return $this->isLong( $m[1] ) && $this->isLong( $m[2] );
437 $this->debug( $in, __FUNCTION__
, 'fed a non-fraction value' );
442 function isUndefined( $in ) {
443 if ( preg_match( "/^\d{4}$/", $in ) ) { // Allow ExifVersion and FlashpixVersion
444 $this->debug( $in, __FUNCTION__
, true );
447 $this->debug( $in, __FUNCTION__
, false );
452 function isSlong( $in ) {
453 if ( $this->isLong( abs( $in ) ) ) {
454 $this->debug( $in, __FUNCTION__
, true );
457 $this->debug( $in, __FUNCTION__
, false );
462 function isSrational( $in ) {
463 if ( preg_match( "/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/", $in, $m ) ) { # Avoid division by zero
464 return $this->isSlong( $m[0] ) && $this->isSlong( $m[1] );
466 $this->debug( $in, __FUNCTION__
, 'fed a non-fraction value' );
473 * Validates if a tag has a legal value according to the Exif spec
475 * @param string $tag The tag to check
476 * @param mixed $val The value of the tag
479 function validate( $tag, $val ) {
480 $debug = "tag is '$tag'";
481 // Fucks up if not typecast
482 switch( (string)$this->mFlatExifTags
[$tag] ) {
483 case (string)MW_EXIF_BYTE
:
484 $this->debug( $val, __FUNCTION__
, $debug );
485 return $this->isByte( $val );
486 case (string)MW_EXIF_ASCII
:
487 $this->debug( $val, __FUNCTION__
, $debug );
488 return $this->isASCII( $val );
489 case (string)MW_EXIF_SHORT
:
490 $this->debug( $val, __FUNCTION__
, $debug );
491 return $this->isShort( $val );
492 case (string)MW_EXIF_LONG
:
493 $this->debug( $val, __FUNCTION__
, $debug );
494 return $this->isLong( $val );
495 case (string)MW_EXIF_RATIONAL
:
496 $this->debug( $val, __FUNCTION__
, $debug );
497 return $this->isRational( $val );
498 case (string)MW_EXIF_UNDEFINED
:
499 $this->debug( $val, __FUNCTION__
, $debug );
500 return $this->isUndefined( $val );
501 case (string)MW_EXIF_SLONG
:
502 $this->debug( $val, __FUNCTION__
, $debug );
503 return $this->isSlong( $val );
504 case (string)MW_EXIF_SRATIONAL
:
505 $this->debug( $val, __FUNCTION__
, $debug );
506 return $this->isSrational( $val );
507 case (string)MW_EXIF_SHORT
.','.MW_EXIF_LONG
:
508 $this->debug( $val, __FUNCTION__
, $debug );
509 return $this->isShort( $val ) ||
$this->isLong( $val );
511 $this->debug( $val, __FUNCTION__
, "The tag '$tag' is unknown" );
517 * Conviniance function for debugging output
520 * @param string $fname
521 * @param mixed $action
523 function debug( $in, $fname, $action = null ) {
524 $type = gettype( $in );
525 $class = ucfirst( __CLASS__
);
526 if ( $type === 'array' )
527 $in = print_r( $in, true );
529 if ( $action === true )
530 wfDebug( "$class::$fname: accepted: '$in' (type: $type)\n");
531 elseif ( $action === false )
532 wfDebug( "$class::$fname: rejected: '$in' (type: $type)\n");
533 elseif ( $action === null )
534 wfDebug( "$class::$fname: input was: '$in' (type: $type)\n");
536 wfDebug( "$class::$fname: $action (type: $type; content: '$in')\n");
543 * @subpackage Metadata
547 * The Exif data to format
557 * @param array $exif The Exif data to format ( as returned by
558 * Exif::getFilteredData() )
560 function FormatExif( $exif ) {
561 $this->mExif
= $exif;
565 * Numbers given by Exif user agents are often magical, that is they
566 * should be replaced by a detailed explanation depending on their
567 * value which most of the time are plain integers. This function
568 * formats Exif values into human readable form.
572 function getFormattedData() {
575 $tags =& $this->mExif
;
577 foreach( $tags as $tag => $val ) {
582 $tags[$tag] = $this->msg( $tag, $val );
590 case 'PhotometricInterpretation':
593 $tags[$tag] = $this->msg( $tag, $val );
603 case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
604 $tags[$tag] = $this->msg( $tag, $val );
612 case 'PlanarConfiguration':
615 $tags[$tag] = $this->msg( $tag, $val );
623 // TODO: YCbCrSubSampling
624 // TODO: YCbCrPositioning
625 // TODO: If this field does not exists use 2
626 case 'ResolutionUnit': #p26
629 $tags[$tag] = $this->msg( $tag, $val );
637 // TODO: YCbCrCoefficients #p27 (see annex E)
638 case 'ExifVersion': case 'FlashpixVersion':
639 $tags[$tag] = "$val"/100;
644 case 1: case 'FFFF.H':
645 $tags[$tag] = $this->msg( $tag, $val );
653 case 'ComponentsConfiguration':
655 case 0: case 1: case 2: case 3: case 4: case 5: case 6:
656 $tags[$tag] = $this->msg( $tag, $val );
665 case 'DateTimeOriginal':
666 case 'DateTimeDigitized':
667 $tags[$tag] = $wgLang->timeanddate( wfTimestamp(TS_MW
, $val) );
670 case 'ExposureProgram':
672 case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
673 $tags[$tag] = $this->msg( $tag, $val );
681 case 'SubjectDistance':
682 $tags[$tag] = $this->msg( $tag, '', $this->formatNum( $val ) );
687 case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 255:
688 $tags[$tag] = $this->msg( $tag, $val );
698 case 0: case 1: case 2: case 3: case 4: case 9: case 10: case 11:
699 case 12: case 13: case 14: case 15: case 17: case 18: case 19: case 20:
700 case 21: case 22: case 23: case 24: case 255:
701 $tags[$tag] = $this->msg( $tag, $val );
710 case 'FocalPlaneResolutionUnit':
713 $tags[$tag] = $this->msg( $tag, $val );
721 case 'SensingMethod':
723 case 1: case 2: case 3: case 4: case 5: case 7: case 8:
724 $tags[$tag] = $this->msg( $tag, $val );
735 $tags[$tag] = $this->msg( $tag, $val );
746 $tags[$tag] = $this->msg( $tag, $val );
754 case 'CustomRendered':
757 $tags[$tag] = $this->msg( $tag, $val );
767 case 0: case 1: case 2:
768 $tags[$tag] = $this->msg( $tag, $val );
779 $tags[$tag] = $this->msg( $tag, $val );
787 case 'SceneCaptureType':
789 case 0: case 1: case 2: case 3:
790 $tags[$tag] = $this->msg( $tag, $val );
800 case 0: case 1: case 2: case 3: case 4:
801 $tags[$tag] = $this->msg( $tag, $val );
811 case 0: case 1: case 2:
812 $tags[$tag] = $this->msg( $tag, $val );
822 case 0: case 1: case 2:
823 $tags[$tag] = $this->msg( $tag, $val );
833 case 0: case 1: case 2:
834 $tags[$tag] = $this->msg( $tag, $val );
842 case 'SubjectDistanceRange':
844 case 0: case 1: case 2: case 3:
845 $tags[$tag] = $this->msg( $tag, $val );
853 case 'GPSLatitudeRef':
854 case 'GPSDestLatitudeRef':
857 $tags[$tag] = $this->msg( 'GPSLatitude', $val );
865 case 'GPSLongitudeRef':
866 case 'GPSDestLongitudeRef':
869 $tags[$tag] = $this->msg( 'GPSLongitude', $val );
880 $tags[$tag] = $this->msg( $tag, $val );
888 case 'GPSMeasureMode':
891 $tags[$tag] = $this->msg( $tag, $val );
900 case 'GPSDestDistanceRef':
902 case 'K': case 'M': case 'N':
903 $tags[$tag] = $this->msg( 'GPSSpeed', $val );
912 case 'GPSImgDirectionRef':
913 case 'GPSDestBearingRef':
916 $tags[$tag] = $this->msg( 'GPSDirection', $val );
925 $tags[$tag] = $wgLang->date( substr( $val, 0, 4 ) . substr( $val, 5, 2 ) . substr( $val, 8, 2 ) . '000000' );
928 // This is not in the Exif standard, just a special
929 // case for our purposes which enables wikis to wikify
930 // the make, model and software name to link to their articles.
934 $tags[$tag] = $this->msg( $tag, '', $val );
937 $tags[$tag] = $this->formatNum( $val );
946 * Conviniance function for getFormattedData()
948 * @param string $tag The tag name to pass on
949 * @param string $val The value of the tag
950 * @param string $arg An argument to pass ($1)
951 * @return string A wfMsg of "exif-$tag-$val" in lower case
953 function msg( $tag, $val, $arg = null ) {
956 return wfMsg( strtolower( "exif-$tag-$val" ), $arg );
960 * @param mixed $num The value to format
961 * @return mixed A floating point number or whatever we were fed
963 function formatNum( $num ) {
964 if ( preg_match( '/^(\d+)\/(\d+)$/', $num, $m ) )
965 return $m[2] != 0 ?
$m[1] / $m[2] : $num;