Class PelIfd

Description

Implements interfaces:

  • IteratorAggregate (internal interface)
  • ArrayAccess (internal interface)

Class representing an Image File Directory (IFD).

TIFF data is structured as a number of Image File Directories, IFDs for short. Each IFD contains a number of entries, some data and finally a link to the next IFD.

Located in /src/PelIfd.php (line 73)


	
			
Class Constant Summary
 EXIF = 2
 GPS = 3
 IFD0 = 0
 IFD1 = 1
Method Summary
static string getTypeName (int $type)
PelIfd __construct (int $type)
void addEntry (PelEntry $e)
void addSubIfd (PelIfd $sub)
void getBytes (int $offset, PelByteOrder $order)
array getEntries ()
Iterator getIterator ()
string getName ()
PelIfd getSubIfd (int $type)
array getSubIfds ()
string getThumbnailData ()
int getType ()
array getValidTags ()
boolean isLastIfd ()
boolean isValidTag (PelTag $tag)
void load (PelDataWindow $d, int $offset)
PelEntry newEntryFromData (PelTag $tag, PelFormat $format, int $components, PelDataWindow $data)
boolean offsetExists (PelTag $tag)
void offsetSet (PelTag $tag, PelEntry $e)
void offsetUnset (PelTag $tag)
void setNextIfd (PelIfd $i)
string __toString ()
Methods
static method getTypeName (line 760)

Get the name of an IFD type.

  • return: the name of type.
static string getTypeName (int $type)
Constructor __construct (line 181)

Construct a new Image File Directory (IFD).

The IFD will be empty, use the addEntry() method to add an PelEntry. Use the setNext() method to link this IFD to another.

PelIfd __construct (int $type)
addEntry (line 799)

Adds an entry to the directory.

  • todo: The entry will be identified with its tag, so each directory can only contain one entry with each tag. Is this a bug?
void addEntry (PelEntry $e)
addSubIfd (line 1009)

Add a sub-IFD.

Any previous sub-IFD of the same type will be overwritten.

void addSubIfd (PelIfd $sub)
getBytes (line 1056)

Turn this directory into bytes.

This directory will be turned into a byte string, with the specified byte order. The offsets will be calculated from the offset given.

void getBytes (int $offset, PelByteOrder $order)
getEntries (line 925)

Returns all entries contained in this IFD.

array getEntries ()
getEntry (line 907)

Retrieve an entry.

  • return: the entry associated with the tag, or null if no such entry exists.
PelEntry getEntry (PelTag $tag)
  • PelTag $tag: the tag identifying the entry.
getIterator (line 944)

Return an iterator for all entries contained in this IFD.

Used with foreach as in

  1.  foreach ($ifd as $tag => $entry{
  2.    // $tag is now a PelTag and $entry is a PelEntry object.
  3.  }

  • return: an iterator using the tags as keys and the entries as values.
Iterator getIterator ()

Implementation of:
IteratorAggregate::getIterator
getName (line 783)

Get the name of this directory.

  • return: the name of this directory.
string getName ()
getNextIfd (line 984)

Return the IFD pointed to by this directory.

  • return: the next IFD, following this IFD. If this is the last IFD, null is returned.
PelIfd getNextIfd ()
getSubIfd (line 1024)

Return a sub IFD.

  • return: the IFD associated with the type, or null if that sub IFD does not exist.
PelIfd getSubIfd (int $type)
getSubIfds (line 1038)

Get all sub IFDs.

  • return: an associative array with (IFD-type, PelIfd) pairs.
array getSubIfds ()
getThumbnailData (line 960)

Returns available thumbnail data.

  • return: the bytes in the thumbnail, if any. If the IFD does not contain any thumbnail data, the empty string is returned.
  • todo: Throw an exception instead when no data is available?
  • todo: Return the $this->thumb_data object instead of the bytes?
string getThumbnailData ()
getType (line 561)

Get the type of this directory.

int getType ()
getValidTags (line 595)

Returns a list of valid tags for this IFD.

  • return: an array of PelTags which are valid for this IFD.
array getValidTags ()
isLastIfd (line 995)

Check if this is the last IFD.

  • return: true if there are no following IFD, false otherwise.
boolean isLastIfd ()
isValidTag (line 584)

Is a given tag valid for this IFD?

Different types of IFDs can contain different kinds of tags --- the IFD0 type, for example, cannot contain a PelTag::GPS_LONGITUDE tag.

A special exception is tags with values above 0xF000. They are treated as private tags and will be allowed everywhere (use this for testing or for implementing your own types of tags).

boolean isValidTag (PelTag $tag)
load (line 199)

Load data into a Image File Directory (IFD).

void load (PelDataWindow $d, int $offset)
  • PelDataWindow $d: the data window that will provide the data.
  • int $offset: the offset within the window where the directory will be found.
newEntryFromData (line 342)

Make a new entry from a bunch of bytes.

This method will create the proper subclass of PelEntry corresponding to the PelTag and PelFormat given. The entry will be initialized with the data given.

Please note that the data you pass to this method should come from an image, that is, it should be raw bytes. If instead you want to create an entry for holding, say, an short integer, then create a PelEntryShort object directly and load the data into it.

A PelUnexpectedFormatException is thrown if a mismatch is discovered between the tag and format, and likewise a PelWrongComponentCountException is thrown if the number of components does not match the requirements of the tag. The requirements for a given tag (if any) can be found in the documentation for PelTag.

  • return: a newly created entry, holding the data given.
PelEntry newEntryFromData (PelTag $tag, PelFormat $format, int $components, PelDataWindow $data)
  • PelTag $tag: the tag of the entry.
  • PelFormat $format: the format of the entry.
  • int $components: the components in the entry.
  • PelDataWindow $data: the data which will be used to construct the entry.
offsetExists (line 826)

Does a given tag exist in this IFD?

This methods is part of the ArrayAccess SPL interface for overriding array access of objects, it allows you to check for existance of an entry in the IFD:

  1.  if (isset($ifd[PelTag::FNUMBER]))
  2.    // ... do something with the F-number.

  • return: whether the tag exists.
boolean offsetExists (PelTag $tag)
  • PelTag $tag: the offset to check.

Implementation of:
ArrayAccess::offsetExists
offsetGet (line 848)

Retrieve a given tag from this IFD.

This methods is part of the ArrayAccess SPL interface for overriding array access of objects, it allows you to read entries from the IFD the same was as for an array:

  1.  $entry $ifd[PelTag::FNUMBER];

  • return: the entry.
PelEntry offsetGet (PelTag $tag)
  • PelTag $tag: the tag to return. It is an error to ask for a tag which is not in the IFD, just like asking for a non-existant array entry.

Implementation of:
ArrayAccess::offsetGet
offsetSet (line 871)

Set or update a given tag in this IFD.

This methods is part of the ArrayAccess SPL interface for overriding array access of objects, it allows you to add new entries or replace esisting entries by doing:

  1.  $ifd[PelTag::EXPOSURE_BIAS_VALUE$entry;

Note that the actual array index passed is ignored! Instead the PelTag from the entry is used.

void offsetSet (PelTag $tag, PelEntry $e)

Implementation of:
ArrayAccess::offsetSet
offsetUnset (line 894)

Unset a given tag in this IFD.

This methods is part of the ArrayAccess SPL interface for overriding array access of objects, it allows you to delete entries in the IFD by doing:

  1.  unset($ifd[PelTag::EXPOSURE_BIAS_VALUE])

void offsetUnset (PelTag $tag)
  • PelTag $tag: the offset to delete.

Implementation of:
ArrayAccess::offsetUnset
setNextIfd (line 973)

Make this directory point to a new directory.

void setNextIfd (PelIfd $i)
  • PelIfd $i: the IFD that this directory will point to.
setThumbnail (line 538)

Set thumbnail data.

Use this to embed an arbitrary JPEG image within this IFD. The data will be checked to ensure that it has a proper PelJpegMarker::EOI at the end. If not, then the length is adjusted until one if found. An PelIfdException might be thrown (depending on Pel::$strict) this case.

void setThumbnail (PelDataWindow $d)
__toString (line 1179)

Turn this directory into text.

  • return: information about the directory, mainly for debugging.
string __toString ()
Class Constants
EXIF = 2 (line 97)

Exif IFD.

Pass this to the constructor when creating an IFD which will be the Exif sub-IFD.

GPS = 3 (line 105)

GPS IFD.

Pass this to the constructor when creating an IFD which will be the GPS sub-IFD.

IFD0 = 0 (line 81)

Main image IFD.

Pass this to the constructor when creating an IFD which will be the IFD of the main image.

IFD1 = 1 (line 89)

Thumbnail image IFD.

Pass this to the constructor when creating an IFD which will be the IFD of the thumbnail image.

INTEROPERABILITY = 4 (line 113)

Interoperability IFD.

Pass this to the constructor when creating an IFD which will be the interoperability sub-IFD.

Documentation generated on Thu, 05 May 2011 07:19:16 +0200 by phpDocumentor 1.4.3