120 # TIFF Rev. 6.0 Attribute Information (p22)
122 # Tags relating to image structure
125 'BitsPerSample' => [
Exif::SHORT, 3 ], # Number
of bits per component
126 # "When a primary image is JPEG compressed, this designation is not"
127 # "necessary and is omitted." (p23)
128 'Compression' =>
Exif::SHORT, # Compression scheme #p23
129 'PhotometricInterpretation' =>
Exif::SHORT, # Pixel composition #p23
133 'YCbCrSubSampling' => [
Exif::SHORT, 2 ], # Subsampling ratio
of Y to C #p24
139 # Tags relating to recording offset
146 # Tags relating to image
data characteristics
149 'PrimaryChromaticities' => [
Exif::RATIONAL, 6 ], # Chromaticities
of primarities
150 # Color space transformation matrix coefficients #p27
157 'Make' =>
Exif::ASCII, # Image input equipment manufacturer
158 'Model' =>
Exif::ASCII, # Image input equipment model
164 #
Exif IFD Attribute Information (p30-31)
166 # @todo NOTE: Nonexistence of this field is taken to mean nonconformance
167 # to the Exif 2.1 AND 2.2 standards
169 'FlashPixVersion' =>
Exif::UNDEFINED, # Supported Flashpix version #p32
171 # Tags relating to Image Data Characteristics
172 'ColorSpace' =>
Exif::SHORT, # Color space information #p32
174 # Tags relating to image configuration
176 'CompressedBitsPerPixel' =>
Exif::RATIONAL, # Image compression mode
180 # Tags relating to related user information
184 # Tags relating to related file information
187 # Tags relating to date and time
191 'SubSecTimeOriginal' =>
Exif::ASCII, # DateTimeOriginal subseconds
192 'SubSecTimeDigitized' =>
Exif::ASCII, # DateTimeDigitized subseconds
194 # Tags relating to picture-taking conditions (p31)
197 'ExposureProgram' =>
Exif::SHORT, # Exposure Program #p38
198 'SpectralSensitivity' =>
Exif::ASCII, # Spectral sensitivity
199 'ISOSpeedRatings' =>
Exif::SHORT, # ISO speed rating
201 # Optoelectronic conversion factor. Note: We don't have support for this atm.
208 'MeteringMode' =>
Exif::SHORT, # Metering mode #p40
212 'SubjectArea' => [
Exif::SHORT, 4 ], # Subject area
214 'SpatialFrequencyResponse' =>
Exif::IGNORE, # Spatial frequency response. Not supported atm.
215 'FocalPlaneXResolution' =>
Exif::RATIONAL, # Focal plane X resolution
216 'FocalPlaneYResolution' =>
Exif::RATIONAL, # Focal plane Y resolution
217 'FocalPlaneResolutionUnit' =>
Exif::SHORT, # Focal plane resolution unit #p46
218 'SubjectLocation' => [
Exif::SHORT, 2 ], # Subject location
220 'SensingMethod' =>
Exif::SHORT, # Sensing method #p46
225 'ExposureMode' =>
Exif::SHORT, # Exposure mode #p48
226 'WhiteBalance' =>
Exif::SHORT, # White Balance #p49
228 'FocalLengthIn35mmFilm' =>
Exif::SHORT, # Focal length
in 35 mm film
230 'GainControl' =>
Exif::SHORT, # Scene control #p49-50
235 # Device settings description. This could maybe be supported. Need to find an
236 # example file that uses this to see if it has stuff of interest in it.
237 'SubjectDistanceRange' =>
Exif::SHORT, # Subject distance range #p51
242 # GPS Attribute Information (p52)
245 # Should be an array of 4 Exif::BYTE's. However php treats it as an undefined
246 # Note exif standard calls this GPSVersionID, but php doesn't like the id suffix
247 'GPSLatitudeRef' =>
Exif::ASCII, # North
or South Latitude #p52-53
249 'GPSLongitudeRef' =>
Exif::ASCII, # East
or West Longitude #p53
252 # Altitude reference. Note, the exif standard says this should be an EXIF::Byte,
253 # but php seems to disagree.
255 'GPSTimeStamp' => [
Exif::RATIONAL, 3 ], # GPS time (atomic clock)
258 'GPSMeasureMode' =>
Exif::ASCII, # Measurement mode #p54-55
262 'GPSTrackRef' =>
Exif::ASCII, # Reference
for direction
of movement #p55
264 'GPSImgDirectionRef' =>
Exif::ASCII, # Reference
for direction
of image #p56
267 'GPSDestLatitudeRef' =>
Exif::ASCII, # Reference
for latitude
of destination #p56
268 'GPSDestLatitude' => [
Exif::RATIONAL, 3 ], # Latitude destination
269 'GPSDestLongitudeRef' =>
Exif::ASCII, # Reference
for longitude
of destination #p57
271 'GPSDestBearingRef' =>
Exif::ASCII, # Reference
for bearing
of destination #p57
273 'GPSDestDistanceRef' =>
Exif::ASCII, # Reference
for distance to destination #p57-58
278 'GPSDifferential' =>
Exif::SHORT, # GPS differential correction
290 wfWarn(
'Exif class did not have byte order specified. ' .
291 'Some properties may be decoded incorrectly.' );
292 $this->byteOrder =
'BE';
295 $this->
debugFile( $this->basename, __FUNCTION__,
true );
296 if ( function_exists(
'exif_read_data' ) ) {
297 MediaWiki\suppressWarnings();
298 $data = exif_read_data( $this->file, 0,
true );
299 MediaWiki\restoreWarnings();
301 throw new MWException(
"Internal error: exif_read_data not present. " .
302 "\$wgShowEXIF may be incorrectly set or not checked by an extension." );
309 $this->mRawExifData = $data ?: [];
319 $this->mFilteredExifData = [];
321 foreach ( array_keys( $this->mRawExifData )
as $section ) {
322 if ( !array_key_exists( $section, $this->mExifTags ) ) {
323 $this->
debug( $section, __FUNCTION__,
"'$section' is not a valid Exif section" );
327 foreach ( array_keys( $this->mRawExifData[$section] )
as $tag ) {
328 if ( !array_key_exists( $tag, $this->mExifTags[$section] ) ) {
329 $this->
debug( $tag, __FUNCTION__,
"'$tag' is not a valid tag in '$section'" );
339 $this->
debug(
$value, __FUNCTION__,
"'$tag' contained invalid data" );
340 unset( $this->mFilteredExifData[$tag] );
371 if ( isset( $this->mFilteredExifData[
'GPSAltitude'] )
372 && isset( $this->mFilteredExifData[
'GPSAltitudeRef'] )
377 list( $num, $denom ) = explode(
'/', $this->mFilteredExifData[
'GPSAltitude'] );
378 $this->mFilteredExifData[
'GPSAltitude'] = $num / $denom;
380 if ( $this->mFilteredExifData[
'GPSAltitudeRef'] ===
"\1" ) {
381 $this->mFilteredExifData[
'GPSAltitude'] *= -1;
383 unset( $this->mFilteredExifData[
'GPSAltitudeRef'] );
396 if ( isset( $this->mFilteredExifData[
'ComponentsConfiguration'] ) ) {
397 $val = $this->mFilteredExifData[
'ComponentsConfiguration'];
400 $strLen = strlen( $val );
401 for ( $i = 0; $i < $strLen; $i++ ) {
402 $ccVals[$i] = ord( substr( $val, $i, 1 ) );
404 $ccVals[
'_type'] =
'ol';
405 $this->mFilteredExifData[
'ComponentsConfiguration'] = $ccVals;
415 if ( isset( $this->mFilteredExifData[
'GPSVersion'] ) ) {
416 $val = $this->mFilteredExifData[
'GPSVersion'];
419 $strLen = strlen( $val );
420 for ( $i = 0; $i < $strLen; $i++ ) {
424 $newVal .= ord( substr( $val, $i, 1 ) );
427 if ( $this->byteOrder ===
'LE' ) {
430 for ( $i = strlen( $newVal ) - 1; $i >= 0; $i-- ) {
431 $newVal2 .= substr( $newVal, $i, 1 );
433 $this->mFilteredExifData[
'GPSVersionID'] = $newVal2;
435 $this->mFilteredExifData[
'GPSVersionID'] = $newVal;
437 unset( $this->mFilteredExifData[
'GPSVersion'] );
448 if ( isset( $this->mFilteredExifData[$prop] ) ) {
450 if ( strlen( $this->mFilteredExifData[$prop] ) <= 8 ) {
453 $this->
debug( $this->mFilteredExifData[$prop], __FUNCTION__,
false );
454 unset( $this->mFilteredExifData[$prop] );
458 $charCode = substr( $this->mFilteredExifData[$prop], 0, 8 );
459 $val = substr( $this->mFilteredExifData[$prop], 8 );
461 switch ( $charCode ) {
462 case "\x4A\x49\x53\x00\x00\x00\x00\x00":
464 $charset =
"Shift-JIS";
474 MediaWiki\suppressWarnings();
475 $val = iconv( $charset,
'UTF-8//IGNORE', $val );
476 MediaWiki\restoreWarnings();
480 UtfNormal\Validator::quickIsNFCVerify( $valCopy );
481 if ( $valCopy !== $val ) {
482 MediaWiki\suppressWarnings();
483 $val = iconv(
'Windows-1252',
'UTF-8//IGNORE', $val );
484 MediaWiki\restoreWarnings();
490 if ( strlen( $val ) === 0 ) {
492 $this->
debug( $this->mFilteredExifData[$prop], __FUNCTION__,
"$prop: Is only whitespace" );
493 unset( $this->mFilteredExifData[$prop] );
499 $this->mFilteredExifData[$prop] = $val;
510 if ( isset( $this->mFilteredExifData[$prop] ) ) {
511 $this->mFilteredExifData[$prop] = ord( $this->mFilteredExifData[$prop] );
521 $loc =& $this->mFilteredExifData[$prop];
522 $dir =& $this->mFilteredExifData[$prop .
'Ref'];
525 if ( isset( $loc ) && isset(
$dir )
528 list( $num, $denom ) = explode(
'/', $loc[0] );
529 $res = $num / $denom;
530 list( $num, $denom ) = explode(
'/', $loc[1] );
531 $res += ( $num / $denom ) * ( 1 / 60 );
532 list( $num, $denom ) = explode(
'/', $loc[2] );
533 $res += ( $num / $denom ) * ( 1 / 3600 );
535 if (
$dir ===
'S' ||
$dir ===
'W' ) {
542 if (
$res !==
false ) {
543 $this->mFilteredExifData[$prop] =
$res;
544 unset( $this->mFilteredExifData[$prop .
'Ref'] );
546 unset( $this->mFilteredExifData[$prop] );
547 unset( $this->mFilteredExifData[$prop .
'Ref'] );
597 if ( !is_array( $in ) && sprintf(
'%d', $in ) == $in && $in >= 0 && $in <= 255 ) {
598 $this->
debug( $in, __FUNCTION__,
true );
602 $this->
debug( $in, __FUNCTION__,
false );
613 if ( is_array( $in ) ) {
617 if ( preg_match(
"/[^\x0a\x20-\x7e]/", $in ) ) {
618 $this->
debug( $in, __FUNCTION__,
'found a character not in our whitelist' );
623 if ( preg_match(
'/^\s*$/', $in ) ) {
624 $this->
debug( $in, __FUNCTION__,
'input consisted solely of whitespace' );
637 if ( !is_array( $in ) && sprintf(
'%d', $in ) == $in && $in >= 0 && $in <= 65536 ) {
638 $this->
debug( $in, __FUNCTION__,
true );
642 $this->
debug( $in, __FUNCTION__,
false );
653 if ( !is_array( $in ) && sprintf(
'%d', $in ) == $in && $in >= 0 && $in <= 4294967296 ) {
654 $this->
debug( $in, __FUNCTION__,
true );
658 $this->
debug( $in, __FUNCTION__,
false );
671 # Avoid division by zero
672 if ( !is_array( $in )
673 && preg_match(
'/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m )
675 return $this->
isLong( $m[1] ) && $this->
isLong( $m[2] );
677 $this->
debug( $in, __FUNCTION__,
'fed a non-fraction value' );
688 $this->
debug( $in, __FUNCTION__,
true );
698 if ( $this->
isLong( abs( $in ) ) ) {
699 $this->
debug( $in, __FUNCTION__,
true );
703 $this->
debug( $in, __FUNCTION__,
false );
716 # Avoid division by zero
717 if ( !is_array( $in ) &&
718 preg_match(
'/^(-?\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m )
722 $this->
debug( $in, __FUNCTION__,
'fed a non-fraction value' );
743 if ( is_array( $etype ) ) {
744 list( $etype, $ecount ) = $etype;
750 if ( $ecount !=
$count ) {
751 $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}'" );
#define the
table suitable for use with IDatabase::select()
you don t have to do a grep find to see where the $wgReverseTitle variable is used
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
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
array $mFilteredExifData
A Filtered version of $mRawExifData that has been pruned of invalid tags and tags that contain conten...
collapseData()
Collapse some fields together.
const SLONG
A 32-bit (4-byte) signed integer (2's complement notation),.
__construct($file, $byteOrder= '')
Constructor.
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 for the local wiki Added in
array $mExifTags
Exif tags grouped by category, the tagname itself is the key and the type is the value, in the case of more than one possible value type they are separated by commas.
isByte($in)
Validates if a tag value is of the type it should be according to the Exif spec.
const BYTE
An 8-bit (1-byte) unsigned integer.
const SRATIONAL
Two SLONGs.
charCodeString($prop)
Do userComment tags and similar.
string $byteOrder
The byte order of the file.
string $basename
The basename of the file being processed.
wfDebugLog($logGroup, $text, $dest= 'all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
string $file
The file being processed.
debugFile($fname, $io)
Convenience function for debugging output.
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
array $mRawExifData
The raw Exif data returned by exif_read_data()
wfWarn($msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
debug($in, $fname, $action=null)
Convenience function for debugging output.
and(b) You must cause any modified files to carry prominent notices stating that You changed the files
const SHORT
A 16-bit (2-byte) unsigned integer.
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
const UNDEFINED
An 8-bit byte that can take any value depending on the field definition.
const ASCII
An 8-bit byte containing one 7-bit ASCII code.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books $tag
exifPropToOrd($prop)
Convert an Exif::UNDEFINED from a raw binary string to its value.
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
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
exifGPStoNumber($prop)
Convert gps in exif form to a single floating point number for example 10 degress 2040` S -> -10...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive false for true for descending in case the handler function wants to provide a converted Content object Note that $result getContentModel() must return $toModel. 'CustomEditor'$rcid is used in generating this variable which contains information about the new such as the revision s whether the revision was marked as a minor edit or not
makeFilteredData()
Make $this->mFilteredExifData.
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
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
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
wfBaseName($path, $suffix= '')
Return the final portion of a pathname.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
const LONG
A 32-bit (4-byte) unsigned integer.
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 prev or next refreshes the diff cache allow viewing deleted revs difference engine object to be used for diff source
const IGNORE
A fake value for things we don't want or don't support.
Class to extract and validate Exif data from jpeg (and possibly tiff) files.
Implements some public methods and some protected utility functions which are required by multiple ch...
string $log
The private log to log to, e.g.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible values
validate($section, $tag, $val, $recursive=false)
#@-
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
getFilteredData()
Get $this->mFilteredExifData.
const SHORT_OR_LONG
A 16-bit (2-byte) or 32-bit (4-byte) unsigned integer.