118 # TIFF Rev. 6.0 Attribute Information (p22)
120 # Tags relating to image structure
123 'BitsPerSample' => [
self::SHORT, 3 ], # Number
of bits per component
124 # "When a primary image is JPEG compressed, this designation is not"
125 # "necessary and is omitted." (p23)
126 'Compression' =>
self::SHORT, # Compression scheme #p23
127 'PhotometricInterpretation' =>
self::SHORT, # Pixel composition #p23
131 'YCbCrSubSampling' => [
self::SHORT, 2 ], # Subsampling ratio
of Y to C #p24
137 # Tags relating to recording offset
138 'StripOffsets' => self::SHORT_OR_LONG, # Image
data location
139 'RowsPerStrip' => self::SHORT_OR_LONG, # Number
of rows per strip
140 'StripByteCounts' => self::SHORT_OR_LONG, # Bytes per compressed strip
141 'JPEGInterchangeFormat' => self::SHORT_OR_LONG, # Offset to JPEG SOI
142 'JPEGInterchangeFormatLength' => self::SHORT_OR_LONG, # Bytes
of JPEG
data
144 # Tags relating to image
data characteristics
145 'TransferFunction' => self::IGNORE, # Transfer
function
146 'WhitePoint' => [ self::RATIONAL, 2 ], # White point chromaticity
147 'PrimaryChromaticities' => [ self::RATIONAL, 6 ], # Chromaticities
of primarities
148 # Color space transformation matrix coefficients #p27
149 'YCbCrCoefficients' => [ self::RATIONAL, 3 ],
150 'ReferenceBlackWhite' => [ self::RATIONAL, 6 ], # Pair
of black
and white reference
values
154 'ImageDescription' => self::ASCII, # Image
title
155 'Make' => self::ASCII, # Image input equipment manufacturer
156 'Model' => self::ASCII, # Image input equipment model
158 'Artist' => self::ASCII, # Person who created the image
159 'Copyright' => self::ASCII, #
Copyright holder
162 #
Exif IFD Attribute Information (p30-31)
164 # @todo NOTE: Nonexistence of this field is taken to mean nonconformance
165 # to the Exif 2.1 AND 2.2 standards
169 # Tags relating to Image Data Characteristics
170 'ColorSpace' =>
self::SHORT, # Color space information #p32
172 # Tags relating to image configuration
174 'CompressedBitsPerPixel' =>
self::RATIONAL, # Image compression mode
178 # Tags relating to related user information
182 # Tags relating to related file information
185 # Tags relating to date and time
189 'SubSecTimeOriginal' =>
self::ASCII, # DateTimeOriginal subseconds
190 'SubSecTimeDigitized' =>
self::ASCII, # DateTimeDigitized subseconds
192 # Tags relating to picture-taking conditions (p31)
195 'ExposureProgram' =>
self::SHORT, # Exposure Program #p38
196 'SpectralSensitivity' =>
self::ASCII, # Spectral sensitivity
197 'ISOSpeedRatings' =>
self::SHORT, # ISO speed rating
199 # Optoelectronic conversion factor. Note: We don't have support for this atm.
206 'MeteringMode' =>
self::SHORT, # Metering mode #p40
210 'SubjectArea' => [
self::SHORT, 4 ], # Subject area
212 'SpatialFrequencyResponse' =>
self::IGNORE, # Spatial frequency response. Not supported atm.
213 'FocalPlaneXResolution' =>
self::RATIONAL, # Focal plane X resolution
214 'FocalPlaneYResolution' =>
self::RATIONAL, # Focal plane Y resolution
215 'FocalPlaneResolutionUnit' =>
self::SHORT, # Focal plane resolution unit #p46
216 'SubjectLocation' => [
self::SHORT, 2 ], # Subject location
218 'SensingMethod' =>
self::SHORT, # Sensing method #p46
221 'CFAPattern' =>
self::IGNORE, # CFA pattern. not supported atm.
223 'ExposureMode' =>
self::SHORT, # Exposure mode #p48
224 'WhiteBalance' =>
self::SHORT, # White Balance #p49
226 'FocalLengthIn35mmFilm' =>
self::SHORT, # Focal length
in 35 mm film
228 'GainControl' =>
self::SHORT, # Scene control #p49-50
233 # Device settings description. This could maybe be supported. Need to find an
234 # example file that uses this to see if it has stuff of interest in it.
235 'SubjectDistanceRange' =>
self::SHORT, # Subject distance range #p51
240 # GPS Attribute Information (p52)
243 # Should be an array of 4 Exif::BYTE's. However php treats it as an undefined
244 # Note exif standard calls this GPSVersionID, but php doesn't like the id suffix
245 'GPSLatitudeRef' =>
self::ASCII, # North
or South Latitude #p52-53
247 'GPSLongitudeRef' =>
self::ASCII, # East
or West Longitude #p53
250 # Altitude reference. Note, the exif standard says this should be an EXIF::Byte,
251 # but php seems to disagree.
253 'GPSTimeStamp' => [
self::RATIONAL, 3 ], # GPS time (atomic clock)
256 'GPSMeasureMode' =>
self::ASCII, # Measurement mode #p54-55
260 'GPSTrackRef' =>
self::ASCII, # Reference
for direction
of movement #p55
262 'GPSImgDirectionRef' =>
self::ASCII, # Reference
for direction
of image #p56
265 'GPSDestLatitudeRef' =>
self::ASCII, # Reference
for latitude
of destination #p56
266 'GPSDestLatitude' => [
self::RATIONAL, 3 ], # Latitude destination
267 'GPSDestLongitudeRef' =>
self::ASCII, # Reference
for longitude
of destination #p57
269 'GPSDestBearingRef' =>
self::ASCII, # Reference
for bearing
of destination #p57
271 'GPSDestDistanceRef' =>
self::ASCII, # Reference
for distance to destination #p57-58
276 'GPSDifferential' =>
self::SHORT, # GPS differential correction
288 wfWarn(
'Exif class did not have byte order specified. ' .
289 'Some properties may be decoded incorrectly.' );
290 $this->byteOrder =
'BE';
293 $this->
debugFile( $this->basename, __FUNCTION__,
true );
294 if ( function_exists(
'exif_read_data' ) ) {
295 Wikimedia\suppressWarnings();
296 $data = exif_read_data( $this->file, 0,
true );
297 Wikimedia\restoreWarnings();
299 throw new MWException(
"Internal error: exif_read_data not present. " .
300 "\$wgShowEXIF may be incorrectly set or not checked by an extension." );
307 $this->mRawExifData = $data ?: [];
317 $this->mFilteredExifData = [];
319 foreach ( array_keys( $this->mRawExifData )
as $section ) {
320 if ( !array_key_exists(
$section, $this->mExifTags ) ) {
321 $this->
debug( $section, __FUNCTION__,
"'$section' is not a valid Exif section" );
325 foreach ( array_keys( $this->mRawExifData[
$section] )
as $tag ) {
326 if ( !array_key_exists( $tag, $this->mExifTags[
$section] ) ) {
327 $this->
debug( $tag, __FUNCTION__,
"'$tag' is not a valid tag in '$section'" );
331 $this->mFilteredExifData[$tag] = $this->mRawExifData[
$section][$tag];
337 $this->
debug(
$value, __FUNCTION__,
"'$tag' contained invalid data" );
338 unset( $this->mFilteredExifData[$tag] );
368 if ( isset( $this->mFilteredExifData[
'GPSAltitude'] )
369 && isset( $this->mFilteredExifData[
'GPSAltitudeRef'] )
374 list( $num, $denom ) = explode(
'/', $this->mFilteredExifData[
'GPSAltitude'] );
375 $this->mFilteredExifData[
'GPSAltitude'] = $num / $denom;
377 if ( $this->mFilteredExifData[
'GPSAltitudeRef'] ===
"\1" ) {
378 $this->mFilteredExifData[
'GPSAltitude'] *= -1;
380 unset( $this->mFilteredExifData[
'GPSAltitudeRef'] );
393 if ( isset( $this->mFilteredExifData[
'ComponentsConfiguration'] ) ) {
394 $val = $this->mFilteredExifData[
'ComponentsConfiguration'];
397 $strLen = strlen( $val );
398 for ( $i = 0; $i < $strLen; $i++ ) {
399 $ccVals[$i] = ord( substr( $val, $i, 1 ) );
401 $ccVals[
'_type'] =
'ol';
402 $this->mFilteredExifData[
'ComponentsConfiguration'] = $ccVals;
412 if ( isset( $this->mFilteredExifData[
'GPSVersion'] ) ) {
413 $val = $this->mFilteredExifData[
'GPSVersion'];
416 $strLen = strlen( $val );
417 for ( $i = 0; $i < $strLen; $i++ ) {
421 $newVal .= ord( substr( $val, $i, 1 ) );
424 if ( $this->byteOrder ===
'LE' ) {
427 for ( $i = strlen( $newVal ) - 1; $i >= 0; $i-- ) {
428 $newVal2 .= substr( $newVal, $i, 1 );
430 $this->mFilteredExifData[
'GPSVersionID'] = $newVal2;
432 $this->mFilteredExifData[
'GPSVersionID'] = $newVal;
434 unset( $this->mFilteredExifData[
'GPSVersion'] );
445 if ( isset( $this->mFilteredExifData[$prop] ) ) {
446 if ( strlen( $this->mFilteredExifData[$prop] ) <= 8 ) {
449 $this->
debug( $this->mFilteredExifData[$prop], __FUNCTION__,
false );
450 unset( $this->mFilteredExifData[$prop] );
454 $charCode = substr( $this->mFilteredExifData[$prop], 0, 8 );
455 $val = substr( $this->mFilteredExifData[$prop], 8 );
457 switch ( $charCode ) {
458 case "\x4A\x49\x53\x00\x00\x00\x00\x00":
460 $charset =
"Shift-JIS";
470 Wikimedia\suppressWarnings();
471 $val = iconv( $charset,
'UTF-8//IGNORE', $val );
472 Wikimedia\restoreWarnings();
476 UtfNormal\Validator::quickIsNFCVerify( $valCopy );
477 if ( $valCopy !== $val ) {
478 Wikimedia\suppressWarnings();
479 $val = iconv(
'Windows-1252',
'UTF-8//IGNORE', $val );
480 Wikimedia\restoreWarnings();
486 if ( strlen( $val ) === 0 ) {
488 $this->
debug( $this->mFilteredExifData[$prop], __FUNCTION__,
"$prop: Is only whitespace" );
489 unset( $this->mFilteredExifData[$prop] );
495 $this->mFilteredExifData[$prop] = $val;
506 if ( isset( $this->mFilteredExifData[$prop] ) ) {
507 $this->mFilteredExifData[$prop] = ord( $this->mFilteredExifData[$prop] );
517 $loc =& $this->mFilteredExifData[$prop];
518 $dir =& $this->mFilteredExifData[$prop .
'Ref'];
521 if ( isset( $loc ) && isset( $dir )
522 && ( $dir ===
'N' || $dir ===
'S' || $dir ===
'E' || $dir ===
'W' )
524 list( $num, $denom ) = explode(
'/', $loc[0] );
525 $res = $num / $denom;
526 list( $num, $denom ) = explode(
'/', $loc[1] );
527 $res += ( $num / $denom ) * ( 1 / 60 );
528 list( $num, $denom ) = explode(
'/', $loc[2] );
529 $res += ( $num / $denom ) * ( 1 / 3600 );
531 if ( $dir ===
'S' || $dir ===
'W' ) {
538 if (
$res !==
false ) {
539 $this->mFilteredExifData[$prop] =
$res;
540 unset( $this->mFilteredExifData[$prop .
'Ref'] );
542 unset( $this->mFilteredExifData[$prop] );
543 unset( $this->mFilteredExifData[$prop .
'Ref'] );
593 if ( !is_array( $in ) && sprintf(
'%d', $in ) == $in && $in >= 0 && $in <= 255 ) {
594 $this->
debug( $in, __FUNCTION__,
true );
598 $this->
debug( $in, __FUNCTION__,
false );
609 if ( is_array( $in ) ) {
613 if ( preg_match(
"/[^\x0a\x20-\x7e]/", $in ) ) {
614 $this->
debug( $in, __FUNCTION__,
'found a character not in our whitelist' );
619 if ( preg_match(
'/^\s*$/', $in ) ) {
620 $this->
debug( $in, __FUNCTION__,
'input consisted solely of whitespace' );
633 if ( !is_array( $in ) && sprintf(
'%d', $in ) == $in && $in >= 0 && $in <= 65536 ) {
634 $this->
debug( $in, __FUNCTION__,
true );
638 $this->
debug( $in, __FUNCTION__,
false );
649 if ( !is_array( $in ) && sprintf(
'%d', $in ) == $in && $in >= 0 && $in <= 4294967296 ) {
650 $this->
debug( $in, __FUNCTION__,
true );
654 $this->
debug( $in, __FUNCTION__,
false );
667 # Avoid division by zero
668 if ( !is_array( $in )
669 && preg_match(
'/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m )
671 return $this->
isLong( $m[1] ) && $this->
isLong( $m[2] );
673 $this->
debug( $in, __FUNCTION__,
'fed a non-fraction value' );
684 $this->
debug( $in, __FUNCTION__,
true );
694 if ( $this->
isLong( abs( $in ) ) ) {
695 $this->
debug( $in, __FUNCTION__,
true );
699 $this->
debug( $in, __FUNCTION__,
false );
712 # Avoid division by zero
713 if ( !is_array( $in ) &&
714 preg_match(
'/^(-?\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m )
718 $this->
debug( $in, __FUNCTION__,
'fed a non-fraction value' );
737 $etype = $this->mExifTags[
$section][$tag];
739 if ( is_array( $etype ) ) {
740 list( $etype, $ecount ) = $etype;
747 if ( is_array( $val ) ) {
748 $count = count( $val );
749 if ( $ecount != $count ) {
750 $this->
debug( $val, __FUNCTION__,
"Expected $ecount elements for $tag but got $count" );
756 foreach ( $val
as $v ) {
765 switch ( (
string)$etype ) {
769 return $this->
isByte( $val );
781 return $this->
isLong( $val );
807 $this->
debug( $val, __FUNCTION__,
"The tag '$tag' is unknown" );
824 $type = gettype( $in );
825 $class = ucfirst( __CLASS__ );
826 if ( is_array( $in ) ) {
827 $in = print_r( $in,
true );
830 if ( $action ===
true ) {
831 wfDebugLog( $this->log,
"$class::$fname: accepted: '$in' (type: $type)" );
832 } elseif ( $action ===
false ) {
833 wfDebugLog( $this->log,
"$class::$fname: rejected: '$in' (type: $type)" );
834 } elseif ( $action ===
null ) {
835 wfDebugLog( $this->log,
"$class::$fname: input was: '$in' (type: $type)" );
837 wfDebugLog( $this->log,
"$class::$fname: $action (type: $type; content: '$in')" );
851 $class = ucfirst( __CLASS__ );
853 wfDebugLog( $this->log,
"$class::$fname: begin processing: '{$this->basename}'" );
855 wfDebugLog( $this->log,
"$class::$fname: end processing: '{$this->basename}'" );
and(b) You must cause any modified files to carry prominent notices stating that You changed the files
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfBaseName( $path, $suffix='')
Return the final portion of a pathname.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Class to extract and validate Exif data from jpeg (and possibly tiff) files.
const SRATIONAL
Two SLONGs.
validate( $section, $tag, $val, $recursive=false)
#-
const BYTE
An 8-bit (1-byte) unsigned integer.
exifPropToOrd( $prop)
Convert an Exif::UNDEFINED from a raw binary string to its value.
const SHORT_OR_LONG
A 16-bit (2-byte) or 32-bit (4-byte) unsigned integer.
string $file
The file being processed.
array $mFilteredExifData
A Filtered version of $mRawExifData that has been pruned of invalid tags and tags that contain conten...
const UNDEFINED
An 8-bit byte that can take any value depending on the field definition.
string $byteOrder
The byte order of the file.
const ASCII
An 8-bit byte containing one 7-bit ASCII code.
getFilteredData()
Get $this->mFilteredExifData.
debug( $in, $fname, $action=null)
Convenience function for debugging output.
const SHORT
A 16-bit (2-byte) unsigned integer.
charCodeString( $prop)
Do userComment tags and similar.
const LONG
A 32-bit (4-byte) unsigned integer.
array $mExifTags
Exif tags grouped by category, the tagname itself is the key and the type is the value,...
array $mRawExifData
The raw Exif data returned by exif_read_data()
__construct( $file, $byteOrder='')
makeFilteredData()
Make $this->mFilteredExifData.
string $log
The private log to log to, e.g.
string $basename
The basename of the file being processed.
collapseData()
Collapse some fields together.
const IGNORE
A fake value for things we don't want or don't support.
debugFile( $fname, $io)
Convenience function for debugging output.
exifGPStoNumber( $prop)
Convert gps in exif form to a single floating point number for example 10 degress 2040` S -> -10....
isByte( $in)
Validates if a tag value is of the type it should be according to the Exif spec.
const SLONG
A 32-bit (4-byte) signed integer (2's complement notation),.
Implements some public methods and some protected utility functions which are required by multiple ch...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could change
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after processing
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible values
null for the local wiki Added in
you don t have to do a grep find to see where the $wgReverseTitle variable is used
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify as strings Extensions should add to this list prev or next refreshes the diff cache allow viewing deleted revs source
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a and VARBINARY columns should simply be TEXT The only exception is when VARBINARY is used to store true binary data
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type