MediaWiki
1.28.0
|
Class to extract and validate Exif data from jpeg (and possibly tiff) files. More...
Public Member Functions | |
__construct ($file, $byteOrder= '') | |
Constructor. More... | |
collapseData () | |
Collapse some fields together. More... | |
getData () | |
#@- More... | |
getFilteredData () | |
Get $this->mFilteredExifData. More... | |
makeFilteredData () | |
Make $this->mFilteredExifData. More... | |
Static Public Member Functions | |
static | version () |
#@- More... | |
Public Attributes | |
const | ASCII = 2 |
An 8-bit byte containing one 7-bit ASCII code. More... | |
const | BYTE = 1 |
An 8-bit (1-byte) unsigned integer. More... | |
const | IGNORE = -1 |
A fake value for things we don't want or don't support. More... | |
const | LONG = 4 |
A 32-bit (4-byte) unsigned integer. More... | |
const | RATIONAL = 5 |
Two LONGs. More... | |
const | SHORT = 3 |
A 16-bit (2-byte) unsigned integer. More... | |
const | SHORT_OR_LONG = 6 |
A 16-bit (2-byte) or 32-bit (4-byte) unsigned integer. More... | |
const | SLONG = 9 |
A 32-bit (4-byte) signed integer (2's complement notation),. More... | |
const | SRATIONAL = 10 |
Two SLONGs. More... | |
const | UNDEFINED = 7 |
An 8-bit byte that can take any value depending on the field definition. More... | |
Private Member Functions | |
charCodeString ($prop) | |
Do userComment tags and similar. More... | |
debug ($in, $fname, $action=null) | |
Convenience function for debugging output. More... | |
debugFile ($fname, $io) | |
Convenience function for debugging output. More... | |
exifGPStoNumber ($prop) | |
Convert gps in exif form to a single floating point number for example 10 degress 2040 ` S -> -10.34444. More... | |
exifPropToOrd ($prop) | |
Convert an Exif::UNDEFINED from a raw binary string to its value. More... | |
isASCII ($in) | |
isByte ($in) | |
Validates if a tag value is of the type it should be according to the Exif spec. More... | |
isLong ($in) | |
isRational ($in) | |
isShort ($in) | |
isSlong ($in) | |
isSrational ($in) | |
isUndefined ($in) | |
validate ($section, $tag, $val, $recursive=false) | |
#@- More... | |
Private Attributes | |
string | $basename |
The basename of the file being processed. More... | |
string | $byteOrder |
The byte order of the file. More... | |
string | $file |
The file being processed. More... | |
string | $log = false |
The private log to log to, e.g. More... | |
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. More... | |
array | $mFilteredExifData |
A Filtered version of $mRawExifData that has been pruned of invalid tags and tags that contain content they shouldn't contain according to the Exif specification. More... | |
array | $mRawExifData |
The raw Exif data returned by exif_read_data() More... | |
Class to extract and validate Exif data from jpeg (and possibly tiff) files.
Exif::__construct | ( | $file, | |
$byteOrder = '' |
|||
) |
Constructor.
string | $file | Filename. |
string | $byteOrder | Type of byte ordering either 'BE' (Big Endian) or 'LE' (Little Endian). Default ''. |
MWException |
Definition at line 110 of file Exif.php.
References $byteOrder, $file, and(), ASCII, change, collapseData(), Copyright(), data, debugFile(), file, IGNORE, in, makeFilteredData(), not, of, or, processing, RATIONAL, SHORT, SHORT_OR_LONG, Software, source, SRATIONAL, the, title, type, UNDEFINED, used, values, version(), wfBaseName(), wfWarn(), and width.
|
private |
Do userComment tags and similar.
See pg. 34 of exif standard. basically first 8 bytes is charset, rest is value. This has not been tested on any shift-JIS strings.
string | $prop | Prop name |
Definition at line 447 of file Exif.php.
References $byteOrder, and debug().
Referenced by collapseData().
Exif::collapseData | ( | ) |
Collapse some fields together.
This converts some fields from exif form, to a more friendly form. For example GPS latitude to a single number.
The rationale behind this is that we're storing data, not presenting to the user For example a longitude is a single number describing how far away you are from the prime meridian. Well it might be nice to split it up into minutes and seconds for the user, it doesn't really make sense to split a single number into 4 parts for storage. (degrees, minutes, second, direction vs single floating point number).
Other things this might do (not really sure if they make sense or not): Dates -> mediawiki date format. convert values that can be in different units to be in one standardized unit.
As an alternative approach, some of this could be done in the validate phase if we make up our own types like Exif::DATE.
Definition at line 364 of file Exif.php.
References charCodeString(), exifGPStoNumber(), exifPropToOrd(), and list.
Referenced by __construct().
|
private |
Convenience function for debugging output.
mixed | $in | Arrays will be processed with print_r(). |
string | $fname | Function name to log. |
string | bool | null | $action | Default null. |
Definition at line 820 of file Exif.php.
References $type, and wfDebugLog().
Referenced by charCodeString(), isASCII(), isByte(), isLong(), isRational(), isShort(), isSlong(), isSrational(), isUndefined(), makeFilteredData(), and validate().
|
private |
Convenience function for debugging output.
string | $fname | The name of the function calling this function |
bool | $io | Specify whether we're beginning or ending |
Definition at line 847 of file Exif.php.
References wfDebugLog().
Referenced by __construct().
|
private |
|
private |
Convert an Exif::UNDEFINED from a raw binary string to its value.
This is sometimes needed depending on the type of UNDEFINED field
string | $prop | Name of property |
Definition at line 509 of file Exif.php.
Referenced by collapseData().
Exif::getData | ( | ) |
#@-
#@+
Definition at line 560 of file Exif.php.
References $mRawExifData.
Exif::getFilteredData | ( | ) |
Get $this->mFilteredExifData.
Definition at line 568 of file Exif.php.
References $mFilteredExifData.
|
private |
mixed | $in | The input value to check |
Definition at line 612 of file Exif.php.
References debug().
Referenced by validate().
|
private |
Validates if a tag value is of the type it should be according to the Exif spec.
mixed | $in | The input value to check |
Definition at line 596 of file Exif.php.
References debug().
Referenced by validate().
|
private |
mixed | $in | The input value to check |
Definition at line 652 of file Exif.php.
References debug().
Referenced by isRational(), isSlong(), and validate().
|
private |
mixed | $in | The input value to check |
Definition at line 668 of file Exif.php.
References debug(), and isLong().
Referenced by validate().
|
private |
mixed | $in | The input value to check |
Definition at line 636 of file Exif.php.
References debug().
Referenced by validate().
|
private |
mixed | $in | The input value to check |
Definition at line 697 of file Exif.php.
References debug(), and isLong().
Referenced by isSrational(), and validate().
|
private |
mixed | $in | The input value to check |
Definition at line 713 of file Exif.php.
References debug(), and isSlong().
Referenced by validate().
|
private |
mixed | $in | The input value to check |
Definition at line 687 of file Exif.php.
References debug().
Referenced by validate().
Exif::makeFilteredData | ( | ) |
Make $this->mFilteredExifData.
Definition at line 318 of file Exif.php.
References $section, $tag, $value, as, debug(), and validate().
Referenced by __construct().
|
private |
#@-
Validates if a tag has a legal value according to the Exif spec
string | $section | Section where tag is located. |
string | $tag | The tag to check. |
mixed | $val | The value of the tag. |
bool | $recursive | True if called recursively for array types. |
Definition at line 739 of file Exif.php.
References $count, $debug, $section, $tag, as, ASCII, BYTE, debug(), IGNORE, isASCII(), isByte(), isLong(), isRational(), isShort(), isSlong(), isSrational(), isUndefined(), list, LONG, RATIONAL, SHORT, SHORT_OR_LONG, SLONG, SRATIONAL, and UNDEFINED.
Referenced by makeFilteredData().
|
static |
#@-
The version of the output format
Before the actual metadata information is saved in the database we strip some of it since we don't want to save things like thumbnails which usually accompany Exif data. This value gets saved in the database along with the actual Exif data, and if the version in the database doesn't equal the value returned by this function the Exif data is regenerated.
Definition at line 586 of file Exif.php.
Referenced by __construct(), TiffHandler\getMetadata(), JpegHandler\getMetadata(), ExifBitmapHandler\isMetadataValid(), and BitmapMetadataHandler\Tiff().
|
private |
|
private |
The byte order of the file.
Needed because php's extension doesn't fully process some obscure props.
Definition at line 96 of file Exif.php.
Referenced by __construct(), and charCodeString().
|
private |
|
private |
|
private |
A Filtered version of $mRawExifData that has been pruned of invalid tags and tags that contain content they shouldn't contain according to the Exif specification.
Definition at line 82 of file Exif.php.
Referenced by getFilteredData().
|
private |
const Exif::ASCII = 2 |
An 8-bit byte containing one 7-bit ASCII code.
The final byte is terminated with NULL.
Definition at line 39 of file Exif.php.
Referenced by __construct(), and validate().
const Exif::BYTE = 1 |
An 8-bit (1-byte) unsigned integer.
Definition at line 34 of file Exif.php.
Referenced by validate().
const Exif::IGNORE = -1 |
A fake value for things we don't want or don't support.
Definition at line 67 of file Exif.php.
Referenced by __construct(), and validate().
const Exif::LONG = 4 |
A 32-bit (4-byte) unsigned integer.
Definition at line 45 of file Exif.php.
Referenced by validate().
const Exif::RATIONAL = 5 |
Two LONGs.
The first LONG is the numerator and the second LONG expresses the denominator
Definition at line 50 of file Exif.php.
Referenced by __construct(), and validate().
const Exif::SHORT = 3 |
A 16-bit (2-byte) unsigned integer.
Definition at line 42 of file Exif.php.
Referenced by __construct(), and validate().
const Exif::SHORT_OR_LONG = 6 |
A 16-bit (2-byte) or 32-bit (4-byte) unsigned integer.
Definition at line 53 of file Exif.php.
Referenced by __construct(), and validate().
const Exif::SLONG = 9 |
A 32-bit (4-byte) signed integer (2's complement notation),.
Definition at line 59 of file Exif.php.
Referenced by validate().
const Exif::SRATIONAL = 10 |
Two SLONGs.
The first SLONG is the numerator and the second SLONG is the denominator.
Definition at line 64 of file Exif.php.
Referenced by __construct(), and validate().
const Exif::UNDEFINED = 7 |
An 8-bit byte that can take any value depending on the field definition.
Definition at line 56 of file Exif.php.
Referenced by __construct(), and validate().