MediaWiki  1.23.1
BitmapMetadataHandler Class Reference

Class to deal with reconciling and extracting metadata from bitmap images. More...

Collaboration diagram for BitmapMetadataHandler:

Public Member Functions

 addMetadata ( $metaArray, $type='other')
 Add misc metadata. More...
 
 getExif ( $filename, $byteOrder)
 Get exif info using exif class. More...
 
 getMetadataArray ()
 Merge together the various types of metadata the different types have different priorites, and are merged in order. More...
 

Static Public Member Functions

static getTiffByteOrder ( $filename)
 Read the first 2 bytes of a tiff file to figure out Little Endian or Big Endian. More...
 
static GIF ( $filename)
 function for gif images. More...
 
static Jpeg ( $filename)
 Main entry point for jpeg's. More...
 
static PNG ( $filename)
 Entry point for png At some point in the future this might merge the png various tEXt chunks to that are interesting, but for now it only does XMP. More...
 
static Tiff ( $filename)
 This doesn't do much yet, but eventually I plan to add XMP support for Tiff. More...
 

Private Member Functions

 doApp13 ( $app13)
 This does the photoshop image resource app13 block of interest, IPTC-IIM metadata is stored here. More...
 

Private Attributes

string $iptcType = 'iptc-no-hash'
 
array $metadata = array()
 
array $metaPriority
 Metadata priority *. More...
 

Detailed Description

Class to deal with reconciling and extracting metadata from bitmap images.

This is meant to comply with http://www.metadataworkinggroup.org/pdf/mwg_guidance.pdf

This sort of acts as an intermediary between MediaHandler::getMetadata and the various metadata extractors.

Todo:
Other image formats.

Definition at line 34 of file BitmapMetadataHandler.php.

Member Function Documentation

◆ addMetadata()

BitmapMetadataHandler::addMetadata (   $metaArray,
  $type = 'other' 
)

Add misc metadata.

Warning: atm if the metadata category doesn't have a priority, it will be silently discarded.

Parameters
array$metaArrayarray of metadata values
string$typeType. defaults to other. if two things have the same type they're merged

Definition at line 100 of file BitmapMetadataHandler.php.

References $type.

Referenced by doApp13(), and getExif().

◆ doApp13()

BitmapMetadataHandler::doApp13 (   $app13)
private

This does the photoshop image resource app13 block of interest, IPTC-IIM metadata is stored here.

Mostly just calls doPSIR and doIPTC

Parameters
string$app13String containing app13 block from jpeg file

Definition at line 58 of file BitmapMetadataHandler.php.

References $e, addMetadata(), JpegMetadataExtractor\doPSIR(), IPTC\parse(), and wfDebug().

◆ getExif()

BitmapMetadataHandler::getExif (   $filename,
  $byteOrder 
)

Get exif info using exif class.

Basically what used to be in BitmapHandler::getMetadata(). Just calls stuff in the Exif class.

Parameters are passed to the Exif class.

Parameters
string$filename
string$byteOrder

Definition at line 83 of file BitmapMetadataHandler.php.

References addMetadata(), and global.

◆ getMetadataArray()

BitmapMetadataHandler::getMetadataArray ( )

Merge together the various types of metadata the different types have different priorites, and are merged in order.

This function is generally called by the media handlers' getMetadata()

Returns
array Metadata array

Definition at line 118 of file BitmapMetadataHandler.php.

References $type, array(), and as.

◆ getTiffByteOrder()

static BitmapMetadataHandler::getTiffByteOrder (   $filename)
static

Read the first 2 bytes of a tiff file to figure out Little Endian or Big Endian.

Needed for exif stuff.

Parameters
string$filenameThe filename
Returns
string 'BE' or 'LE' or false

Definition at line 294 of file BitmapMetadataHandler.php.

Referenced by Tiff().

◆ GIF()

static BitmapMetadataHandler::GIF (   $filename)
static

function for gif images.

They don't really have native metadata, so just merges together XMP and image comment.

Parameters
string$filenamefull path to file
Returns
array Metadata array

Definition at line 227 of file BitmapMetadataHandler.php.

References $type, array(), as, GIFMetadataExtractor\getMetadata(), and GIFMetadataExtractor\VERSION.

Referenced by GIFHandler\getMetadata().

◆ Jpeg()

static BitmapMetadataHandler::Jpeg (   $filename)
static

Main entry point for jpeg's.

Parameters
string$filenamefilename (with full path)
Returns
array Metadata result array.
Exceptions
MWExceptionon invalid file.

Definition at line 153 of file BitmapMetadataHandler.php.

References $res, $type, array(), as, and JpegMetadataExtractor\segmentSplitter().

Referenced by JpegHandler\getMetadata(), BitmapMetadataHandlerTest\testBadIPTC(), BitmapMetadataHandlerTest\testIPTCDates(), BitmapMetadataHandlerTest\testIPTCDatesInvalid(), BitmapMetadataHandlerTest\testJpegComment(), and BitmapMetadataHandlerTest\testMultilingualCascade().

◆ PNG()

static BitmapMetadataHandler::PNG (   $filename)
static

Entry point for png At some point in the future this might merge the png various tEXt chunks to that are interesting, but for now it only does XMP.

Parameters
string$filenameFull path to file
Returns
array Array for storage in img_metadata.

Definition at line 195 of file BitmapMetadataHandler.php.

References $type, as, PNGMetadataExtractor\getMetadata(), and PNGMetadataExtractor\VERSION.

Referenced by PNGHandler\getMetadata().

◆ Tiff()

static BitmapMetadataHandler::Tiff (   $filename)
static

This doesn't do much yet, but eventually I plan to add XMP support for Tiff.

(PHP's exif support already extracts but needs some further processing because PHP's exif support is stupid...)

Todo:
Add XMP support, so this function actually makes sense to put here.

The various exceptions this throws are caught later.

Parameters
string$filename
Exceptions
MWException
Returns
array The metadata.

Definition at line 267 of file BitmapMetadataHandler.php.

References getTiffByteOrder(), and Exif\version().

Referenced by TiffHandler\getMetadata().

Member Data Documentation

◆ $iptcType

string BitmapMetadataHandler::$iptcType = 'iptc-no-hash'
private

Definition at line 48 of file BitmapMetadataHandler.php.

◆ $metadata

array BitmapMetadataHandler::$metadata = array()
private

Definition at line 35 of file BitmapMetadataHandler.php.

◆ $metaPriority

array BitmapMetadataHandler::$metaPriority
private
Initial value:
20 => array( 'other' ),
40 => array( 'native' ),
60 => array( 'iptc-good-hash', 'iptc-no-hash' ),
70 => array( 'xmp-deprecated' ),
80 => array( 'xmp-general' ),
90 => array( 'xmp-exif' ),
100 => array( 'iptc-bad-hash' ),
120 => array( 'exif' ),
)

Metadata priority *.

Definition at line 37 of file BitmapMetadataHandler.php.


The documentation for this class was generated from the following file:
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.