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
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__
, true );
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 $this->debug( $in, __FUNCTION__
);
444 if ( preg_match( "/^\d{4}$/", $in ) ) { // Allow ExifVersion and FlashpixVersion
451 function isSlong( $in ) {
452 if ( $this->isLong( abs( $in ) ) ) {
453 $this->debug( $in, __FUNCTION__
, true );
456 $this->debug( $in, __FUNCTION__
, false );
461 function isSrational( $in ) {
462 if ( preg_match( "/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/", $in, $m ) ) { # Avoid division by zero
463 return $this->isSlong( $m[0] ) && $this->isSlong( $m[1] );
465 $this->debug( $in, __FUNCTION__
, 'fed a non-fraction value' );
472 * Validates if a tag has a legal value according to the Exif spec
474 * @param string $tag The tag to check
475 * @param mixed $val The value of the tag
478 function validate( $tag, $val ) {
479 // Fucks up if not typecast
480 switch( (string)$this->mFlatExifTags
[$tag] ) {
481 case (string)MW_EXIF_BYTE
:
482 return $this->isByte( $val );
483 case (string)MW_EXIF_ASCII
:
484 return $this->isASCII( $val );
485 case (string)MW_EXIF_SHORT
:
486 return $this->isShort( $val );
487 case (string)MW_EXIF_LONG
:
488 return $this->isLong( $val );
489 case (string)MW_EXIF_RATIONAL
:
490 return $this->isRational( $val );
491 case (string)MW_EXIF_UNDEFINED
:
492 return $this->isUndefined( $val );
493 case (string)MW_EXIF_SLONG
:
494 return $this->isSlong( $val );
495 case (string)MW_EXIF_SRATIONAL
:
496 return $this->isSrational( $val );
497 case (string)MW_EXIF_SHORT
.','.MW_EXIF_LONG
:
498 return $this->isShort( $val ) ||
$this->isLong( $val );
500 $this->debug( $val, __FUNCTION__
, "The tag '$tag' is unknown" );
506 * Conviniance function for debugging output
509 * @param string $fname
510 * @param mixed $action
512 function debug( $in, $fname, $action = null ) {
513 $type = gettype( $in );
514 $class = ucfirst( __CLASS__
);
515 if ( $type === 'array' )
516 $in = print_r( $in, true );
518 if ( $action === true )
519 wfDebug( "$class::$fname: accepted: '$in' (type: $type)\n");
520 elseif ( $action === false )
521 wfDebug( "$class::$fname: rejected: '$in' (type: $type)\n");
522 elseif ( $action === null )
523 wfDebug( "$class::$fname: input was: '$in' (type: $type)\n");
525 wfDebug( "$class::$fname: $action (type: $type; content: '$in')\n");
532 * @subpackage Metadata
536 * The Exif data to format
546 * @param array $exif The Exif data to format ( as returned by
547 * Exif::getFilteredData() )
549 function FormatExif( $exif ) {
550 $this->mExif
= $exif;
554 * Numbers given by Exif user agents are often magical, that is they
555 * should be replaced by a detailed explanation depending on their
556 * value which most of the time are plain integers. This function
557 * formats Exif values into human readable form.
561 function getFormattedData() {
564 $tags =& $this->mExif
;
566 foreach( $tags as $tag => $val ) {
571 $tags[$tag] = $this->msg( $tag, $val );
578 case 'PhotometricInterpretation':
581 $tags[$tag] = $this->msg( $tag, $val );
590 case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
591 $tags[$tag] = $this->msg( $tag, $val );
598 case 'PlanarConfiguration':
601 $tags[$tag] = $this->msg( $tag, $val );
608 // TODO: YCbCrSubSampling
609 // TODO: YCbCrPositioning
610 // TODO: If this field does not exists use 2
611 case 'ResolutionUnit': #p26
614 $tags[$tag] = $this->msg( $tag, $val );
621 // TODO: YCbCrCoefficients #p27 (see annex E)
622 case 'ExifVersion': case 'FlashpixVersion':
623 $tags[$tag] = "$val"/100;
628 case 1: case 'FFFF.H':
629 $tags[$tag] = $this->msg( $tag, $val );
636 case 'ComponentsConfiguration':
638 case 0: case 1: case 2: case 3: case 4: case 5: case 6:
639 $tags[$tag] = $this->msg( $tag, $val );
647 case 'DateTimeOriginal':
648 case 'DateTimeDigitized':
649 $tags[$tag] = $wgLang->timeanddate( wfTimestamp(TS_MW
, $val) );
652 case 'ExposureProgram':
654 case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
655 $tags[$tag] = $this->msg( $tag, $val );
664 case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 255:
665 $tags[$tag] = $this->msg( $tag, $val );
674 case 0: case 1: case 2: case 3: case 4: case 9: case 10: case 11:
675 case 12: case 13: case 14: case 15: case 17: case 18: case 19: case 20:
676 case 21: case 22: case 23: case 24: case 255:
677 $tags[$tag] = $this->msg( $tag, $val );
685 case 'SensingMethod':
687 case 1: case 2: case 3: case 4: case 5: case 7: case 8:
688 $tags[$tag] = $this->msg( $tag, $val );
698 $tags[$tag] = $this->msg( $tag, $val );
708 $tags[$tag] = $this->msg( $tag, $val );
715 case 'CustomRendered':
718 $tags[$tag] = $this->msg( $tag, $val );
727 case 0: case 1: case 2:
728 $tags[$tag] = $this->msg( $tag, $val );
738 $tags[$tag] = $this->msg( $tag, $val );
745 case 'SceneCaptureType':
747 case 0: case 1: case 2: case 3:
748 $tags[$tag] = $this->msg( $tag, $val );
757 case 0: case 1: case 2: case 3: case 4:
758 $tags[$tag] = $this->msg( $tag, $val );
767 case 0: case 1: case 2:
768 $tags[$tag] = $this->msg( $tag, $val );
777 case 0: case 1: case 2:
778 $tags[$tag] = $this->msg( $tag, $val );
787 case 0: case 1: case 2:
788 $tags[$tag] = $this->msg( $tag, $val );
795 case 'SubjectDistanceRange':
797 case 0: case 1: case 2: case 3:
798 $tags[$tag] = $this->msg( $tag, $val );
805 case 'GPSLatitudeRef':
806 case 'GPSDestLatitudeRef':
809 $tags[$tag] = $this->msg( 'GPSLatitude', $val );
816 case 'GPSLongitudeRef':
817 case 'GPSDestLongitudeRef':
820 $tags[$tag] = $this->msg( 'GPSLongitude', $val );
830 $tags[$tag] = $this->msg( $tag, $val );
837 case 'GPSMeasureMode':
840 $tags[$tag] = $this->msg( $tag, $val );
848 case 'GPSDestDistanceRef':
850 case 'K': case 'M': case 'N':
851 $tags[$tag] = $this->msg( 'GPSSpeed', $val );
859 case 'GPSImgDirectionRef':
860 case 'GPSDestBearingRef':
863 $tags[$tag] = $this->msg( 'GPSDirection', $val );
871 $tags[$tag] = $wgLang->date( substr( $val, 0, 4 ) . substr( $val, 5, 2 ) . substr( $val, 8, 2 ) . '000000' );
874 // This is not in the Exif standard, just a special
875 // case for our purposes which enables wikis to wikify
876 // the make, model and software name to link to their articles.
880 $tags[$tag] = wfMsg( strtolower( "exif-$tag-value" ), $val );
883 if ( preg_match( '/^(\d+)\/(\d+)$/', $val, $m ) ) {
884 $tags[$tag] = $m[2] != 0 ?
$m[1]/$m[2] : $val;
896 * Conviniance function for format()
898 * @param string $tag The tag name to pass on
899 * @param string $val The value of the tag
900 * @return string A wfMsg of "exif-$tag-$val" in lower case
902 function msg( $tag, $val ) {
903 return wfMsg( strtolower("exif-$tag-$val") );