MediaWiki  REL1_19
Exif Class Reference

Class to extract and validate Exif data from jpeg (and possibly tiff) files. More...

List of all members.

Public Member Functions

 __construct ($file, $byteOrder= '')
 Constructor.
 collapseData ()
 Collapse some fields together.
 getData ()
 #@-
 getFilteredData ()
 Get $this->mFilteredExifData.
 getFormattedData ()
 Get $this->mFormattedExifData.
 makeFilteredData ()
 Make $this->mFilteredExifData.
 makeFormattedData ()
 Use FormatMetadata to create formatted values for display to user (is this ever used?)

Static Public Member Functions

static version ()
 #@-

Public Attributes

const ASCII = 2
 An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL.
const BYTE = 1
 An 8-bit (1-byte) unsigned integer.
const IGNORE = -1
const LONG = 4
 A 32-bit (4-byte) unsigned integer.
const RATIONAL = 5
 Two LONGs. The first LONG is the numerator and the second LONG expresses the denominator.
const SHORT = 3
 A 16-bit (2-byte) unsigned integer.
const SLONG = 9
 A 32-bit (4-byte) signed integer (2's complement notation),.
const SRATIONAL = 10
 Two SLONGs. The first SLONG is the numerator and the second SLONG is the denominator.
const UNDEFINED = 7
 An 8-bit byte that can take any value depending on the field definition.
 $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.
 $mRawExifData
 The raw Exif data returned by exif_read_data()
 $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.
 $mFormattedExifData
 Filtered and formatted Exif data, see FormatMetadata::getFormattedData()

Private Member Functions

 charCodeString ($prop)
 Do userComment tags and similar.
 debug ($in, $fname, $action=null)
 Convenience function for debugging output.
 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 20`40`` S -> -10.34444.
 exifPropToOrd ($prop)
 Convert an Exif::UNDEFINED from a raw binary string to its value.
 isASCII ($in)
 isByte ($in)
 #@+ Validates if a tag value is of the type it should be according to the Exif spec
 isLong ($in)
 isRational ($in)
 isShort ($in)
 isSlong ($in)
 isSrational ($in)
 isUndefined ($in)
 validate ($section, $tag, $val, $recursive=false)
 #@-
 $file
 The file being processed.
 $basename
 The basename of the file being processed.
 $log = false
 The private log to log to, e.g.
 $byteOrder
 The byte order of the file.

Detailed Description

Class to extract and validate Exif data from jpeg (and possibly tiff) files.

Definition at line 30 of file Exif.php.


Constructor & Destructor Documentation

Exif::__construct ( file,
byteOrder = '' 
)

Constructor.

Parameters:
$fileString: filename.
$byteOrderString Type of byte ordering either 'BE' (Big Endian) or 'LE' (Little Endian). Default ''.
Todo:
FIXME: The following are broke: SubjectArea. Need to test the more obscure tags.

DigitalZoomRatio = 0/0 is rejected. need to determine if that's valid. possibly should treat 0/0 = 0. need to read exif spec on that.

Definition at line 111 of file Exif.php.

References ASCII, IGNORE, LONG, RATIONAL, SHORT, UNDEFINED, version(), and wfWarn().

Here is the call graph for this function:


Member Function Documentation

Exif::charCodeString ( prop) [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.

Parameters:
$propString prop name.

Definition at line 433 of file Exif.php.

References UtfNormal\quickIsNFCVerify(), wfRestoreWarnings(), and wfSuppressWarnings().

Here is the call graph for this function:

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 363 of file Exif.php.

Exif::debug ( in,
fname,
action = null 
) [private]

Convenience function for debugging output.

Access:
private
Parameters:
$inMixed:
$fnameString:
$actionMixed: , default NULL.

Definition at line 796 of file Exif.php.

References $in, and wfDebugLog().

Here is the call graph for this function:

Exif::debugFile ( fname,
io 
) [private]

Convenience function for debugging output.

Access:
private
Parameters:
$fnameString: the name of the function calling this function
$ioBoolean: Specify whether we're beginning or ending

Definition at line 825 of file Exif.php.

References wfDebugLog().

Here is the call graph for this function:

Exif::exifGPStoNumber ( prop) [private]

Convert gps in exif form to a single floating point number for example 10 degress 20`40`` S -> -10.34444.

Parameters:
String$propa gps coordinate exif tag name (like GPSLongitude)

Definition at line 505 of file Exif.php.

References $dir, and $res.

Exif::exifPropToOrd ( prop) [private]

Convert an Exif::UNDEFINED from a raw binary string to its value.

This is sometimes needed depending on the type of UNDEFINED field

Parameters:
$propString name of property

Definition at line 495 of file Exif.php.

#@-

#@+

Returns:
array Get $this->mRawExifData

Definition at line 553 of file Exif.php.

Get $this->mFilteredExifData.

Definition at line 560 of file Exif.php.

Get $this->mFormattedExifData.

This returns the data for display to user. Its unclear if this is ever used.

Deprecated:
since 1.18

Definition at line 572 of file Exif.php.

References wfDeprecated().

Here is the call graph for this function:

Exif::isASCII ( in) [private]
Parameters:
$in
Returns:
bool

Definition at line 619 of file Exif.php.

References $in.

Exif::isByte ( in) [private]

#@+ Validates if a tag value is of the type it should be according to the Exif spec

Access:
private
Parameters:
$inMixed: the input value to check
Returns:
bool

Definition at line 605 of file Exif.php.

References $in.

Exif::isLong ( in) [private]
Parameters:
$in
Returns:
bool

Definition at line 655 of file Exif.php.

References $in.

Exif::isRational ( in) [private]
Parameters:
$in
Returns:
bool

Definition at line 669 of file Exif.php.

References $in.

Exif::isShort ( in) [private]
Parameters:
$in
Returns:
bool

Definition at line 641 of file Exif.php.

References $in.

Exif::isSlong ( in) [private]
Parameters:
$in
Returns:
bool

Definition at line 692 of file Exif.php.

References $in.

Exif::isSrational ( in) [private]
Parameters:
$in
Returns:
bool

Definition at line 706 of file Exif.php.

References $in.

Exif::isUndefined ( in) [private]
Parameters:
$in
Returns:
bool

Definition at line 683 of file Exif.php.

References $in.

Make $this->mFilteredExifData.

Definition at line 317 of file Exif.php.

References $section.

Use FormatMetadata to create formatted values for display to user (is this ever used?)

Deprecated:
since 1.18

Definition at line 540 of file Exif.php.

References FormatMetadata\getFormattedData(), and wfDeprecated().

Here is the call graph for this function:

Exif::validate ( section,
tag,
val,
recursive = false 
) [private]

#@-

Validates if a tag has a legal value according to the Exif spec

Access:
private
Parameters:
$sectionString: section where tag is located.
$tagString: the tag to check.
$valMixed: the value of the tag.
$recursiveBoolean: true if called recursively for array types.
Returns:
bool

Definition at line 727 of file Exif.php.

References $count, $section, ASCII, BYTE, IGNORE, LONG, RATIONAL, SHORT, SLONG, SRATIONAL, and UNDEFINED.

static Exif::version ( ) [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.

Returns:
int

Definition at line 593 of file Exif.php.

Referenced by __construct(), JpegHandler\getMetadata(), TiffHandler\getMetadata(), ExifBitmapHandler\isMetadataValid(), and BitmapMetadataHandler\Tiff().

Here is the caller graph for this function:


Member Data Documentation

Exif::$basename

The basename of the file being processed.

Definition at line 86 of file Exif.php.

Exif::$byteOrder [private]

The byte order of the file.

Needed because php's extension doesn't fully process some obscure props.

Definition at line 97 of file Exif.php.

Exif::$file

The file being processed.

Definition at line 81 of file Exif.php.

Exif::$log = false

The private log to log to, e.g.

'exif'

Definition at line 91 of file Exif.php.

Exif::$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.

Definition at line 52 of file Exif.php.

Exif::$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.

Definition at line 64 of file Exif.php.

Exif::$mFormattedExifData

Filtered and formatted Exif data, see FormatMetadata::getFormattedData()

Definition at line 69 of file Exif.php.

Exif::$mRawExifData

The raw Exif data returned by exif_read_data()

Definition at line 57 of file Exif.php.

const Exif::ASCII = 2

An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL.

Definition at line 33 of file Exif.php.

Referenced by __construct(), and validate().

const Exif::BYTE = 1

An 8-bit (1-byte) unsigned integer.

Definition at line 32 of file Exif.php.

Referenced by validate().

const Exif::IGNORE = -1

Definition at line 40 of file Exif.php.

Referenced by __construct(), and validate().

const Exif::LONG = 4

A 32-bit (4-byte) unsigned integer.

Definition at line 35 of file Exif.php.

Referenced by __construct(), and validate().

const Exif::RATIONAL = 5

Two LONGs. The first LONG is the numerator and the second LONG expresses the denominator.

Definition at line 36 of file Exif.php.

Referenced by __construct(), and validate().

const Exif::SHORT = 3

A 16-bit (2-byte) unsigned integer.

Definition at line 34 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 38 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 39 of file Exif.php.

Referenced by validate().

const Exif::UNDEFINED = 7

An 8-bit byte that can take any value depending on the field definition.

Definition at line 37 of file Exif.php.

Referenced by __construct(), and validate().


The documentation for this class was generated from the following file: