PHP Класс lsolesen\pel\PelIfd

{@link PelTiff TIFF data} is structured as a number of Image File Directories, IFDs for short. Each IFD contains a number of {@link PelEntry entries}, some data and finally a link to the next IFD.
Автор: Martin Geisler ([email protected])
Наследование: implements IteratorAggregate, implements ArrayAccess
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( $type ) Construct a new Image File Directory (IFD).
__toString ( ) : string Turn this directory into text.
addEntry ( lsolesen\pel\PelEntry $e ) Adds an entry to the directory.
addSubIfd ( PelIfd $sub ) Add a sub-IFD.
getBytes ( integer $offset, PelByteOrder $order ) Turn this directory into bytes.
getEntries ( ) : array Returns all entries contained in this IFD.
getEntry ( lsolesen\pel\PelTag $tag ) : lsolesen\pel\PelEntry Retrieve an entry.
getIterator ( ) : Iterator Return an iterator for all entries contained in this IFD.
getName ( ) : string Get the name of this directory.
getNextIfd ( ) : PelIfd Return the IFD pointed to by this directory.
getSubIfd ( integer $type ) : PelIfd Return a sub IFD.
getSubIfds ( ) : array Get all sub IFDs.
getThumbnailData ( ) : string Returns available thumbnail data.
getType ( ) : integer Get the type of this directory.
getTypeName ( integer $type ) : string Get the name of an IFD type.
getValidTags ( ) : array Returns a list of valid tags for this IFD.
isLastIfd ( ) : boolean Check if this is the last IFD.
isValidTag ( lsolesen\pel\PelTag $tag ) : boolean Is a given tag valid for this IFD?
load ( lsolesen\pel\PelDataWindow $d, integer $offset ) Load data into a Image File Directory (IFD).
newEntryFromData ( lsolesen\pel\PelTag $tag, lsolesen\pel\PelFormat $format, integer $components, lsolesen\pel\PelDataWindow $data ) : lsolesen\pel\PelEntry Make a new entry from a bunch of bytes.
offsetExists ( lsolesen\pel\PelTag $tag ) : boolean Does a given tag exist in this IFD?
offsetGet ( lsolesen\pel\PelTag $tag ) : lsolesen\pel\PelEntry Retrieve a given tag from this IFD.
offsetSet ( lsolesen\pel\PelTag $tag, lsolesen\pel\PelEntry $e ) Set or update a given tag in this IFD.
offsetUnset ( lsolesen\pel\PelTag $tag ) Unset a given tag in this IFD.
setNextIfd ( PelIfd $i ) Make this directory point to a new directory.
setThumbnail ( lsolesen\pel\PelDataWindow $d ) Set thumbnail data.

Приватные методы

Метод Описание
safeSetThumbnail ( lsolesen\pel\PelDataWindow $d, integer $offset, integer $length ) Extract thumbnail data safely.

Описание методов

__construct() публичный Метод

The IFD will be empty, use the {@link addEntry()} method to add an {@link PelEntry}. Use the {@link setNext()} method to link this IFD to another.
public __construct ( $type )

__toString() публичный Метод

Turn this directory into text.
public __toString ( ) : string
Результат string information about the directory, mainly for debugging.

addEntry() публичный Метод

Adds an entry to the directory.
public addEntry ( lsolesen\pel\PelEntry $e )
$e lsolesen\pel\PelEntry the entry that will be added. If the entry is not valid in this IFD (as per {@link isValidTag()}) an {@link PelInvalidDataException} is thrown.

addSubIfd() публичный Метод

Any previous sub-IFD of the same type will be overwritten.
public addSubIfd ( PelIfd $sub )
$sub PelIfd the sub IFD. The type of must be one of {@link PelIfd::EXIF}, {@link PelIfd::GPS}, or {@link PelIfd::INTEROPERABILITY}.

getBytes() публичный Метод

This directory will be turned into a byte string, with the specified byte order. The offsets will be calculated from the offset given.
public getBytes ( integer $offset, PelByteOrder $order )
$offset integer the offset of the first byte of this directory.
$order PelByteOrder the byte order that should be used when turning integers into bytes. This should be one of {@link PelConvert::LITTLE_ENDIAN} and {@link PelConvert::BIG_ENDIAN}.

getEntries() публичный Метод

Returns all entries contained in this IFD.
См. также: getEntry
См. также: getIterator
public getEntries ( ) : array
Результат array an array of {@link PelEntry} objects, or rather descendant classes. The array has {@link PelTag}s as keys and the entries as values.

getEntry() публичный Метод

Retrieve an entry.
public getEntry ( lsolesen\pel\PelTag $tag ) : lsolesen\pel\PelEntry
$tag lsolesen\pel\PelTag the tag identifying the entry.
Результат lsolesen\pel\PelEntry the entry associated with the tag, or null if no such entry exists.

getIterator() публичный Метод

Used with foreach as in foreach ($ifd as $tag => $entry) { $tag is now a PelTag and $entry is a PelEntry object. }
public getIterator ( ) : Iterator
Результат Iterator an iterator using the {@link PelTag tags} as keys and the entries as values.

getName() публичный Метод

Get the name of this directory.
public getName ( ) : string
Результат string the name of this directory.

getNextIfd() публичный Метод

Return the IFD pointed to by this directory.
public getNextIfd ( ) : PelIfd
Результат PelIfd the next IFD, following this IFD. If this is the last IFD, null is returned.

getSubIfd() публичный Метод

Return a sub IFD.
public getSubIfd ( integer $type ) : PelIfd
$type integer the type of the sub IFD. This must be one of {@link PelIfd::EXIF}, {@link PelIfd::GPS}, or {@link PelIfd::INTEROPERABILITY}.
Результат PelIfd the IFD associated with the type, or null if that sub IFD does not exist.

getSubIfds() публичный Метод

Get all sub IFDs.
public getSubIfds ( ) : array
Результат array an associative array with (IFD-type, {@link PelIfd}) pairs.

getThumbnailData() публичный Метод

Returns available thumbnail data.
public getThumbnailData ( ) : string
Результат string the bytes in the thumbnail, if any. If the IFD does not contain any thumbnail data, the empty string is returned.

getType() публичный Метод

Get the type of this directory.
public getType ( ) : integer
Результат integer of {@link PelIfd::IFD0}, {@link PelIfd::IFD1}, {@link PelIfd::EXIF}, {@link PelIfd::GPS}, or {@link PelIfd::INTEROPERABILITY}.

getTypeName() публичный статический Метод

Get the name of an IFD type.
public static getTypeName ( integer $type ) : string
$type integer one of {@link PelIfd::IFD0}, {@link PelIfd::IFD1}, {@link PelIfd::EXIF}, {@link PelIfd::GPS}, or {@link PelIfd::INTEROPERABILITY}.
Результат string the name of type.

getValidTags() публичный Метод

Returns a list of valid tags for this IFD.
public getValidTags ( ) : array
Результат array an array of {@link PelTag}s which are valid for this IFD.

isLastIfd() публичный Метод

Check if this is the last IFD.
public isLastIfd ( ) : boolean
Результат boolean true if there are no following IFD, false otherwise.

isValidTag() публичный Метод

Different types of IFDs can contain different kinds of tags --- the {@link IFD0} type, for example, cannot contain a {@link 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).
См. также: getValidTags()
public isValidTag ( lsolesen\pel\PelTag $tag ) : boolean
$tag lsolesen\pel\PelTag the tag.
Результат boolean true if the tag is considered valid in this IFD, false otherwise.

load() публичный Метод

Load data into a Image File Directory (IFD).
public load ( lsolesen\pel\PelDataWindow $d, integer $offset )
$d lsolesen\pel\PelDataWindow the data window that will provide the data.
$offset integer the offset within the window where the directory will be found.

newEntryFromData() публичный Метод

This method will create the proper subclass of {@link PelEntry} corresponding to the {@link PelTag} and {@link 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 {@link PelEntryShort} object directly and load the data into it. A {@link PelUnexpectedFormatException} is thrown if a mismatch is discovered between the tag and format, and likewise a {@link 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 {@link PelTag}.
public newEntryFromData ( lsolesen\pel\PelTag $tag, lsolesen\pel\PelFormat $format, integer $components, lsolesen\pel\PelDataWindow $data ) : lsolesen\pel\PelEntry
$tag lsolesen\pel\PelTag the tag of the entry.
$format lsolesen\pel\PelFormat the format of the entry.
$components integer the components in the entry.
$data lsolesen\pel\PelDataWindow the data which will be used to construct the entry.
Результат lsolesen\pel\PelEntry a newly created entry, holding the data given.

offsetExists() публичный Метод

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: if (isset($ifd[PelTag::FNUMBER])) ... do something with the F-number.
public offsetExists ( lsolesen\pel\PelTag $tag ) : boolean
$tag lsolesen\pel\PelTag the offset to check.
Результат boolean whether the tag exists.

offsetGet() публичный Метод

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: $entry = $ifd[PelTag::FNUMBER];
public offsetGet ( lsolesen\pel\PelTag $tag ) : lsolesen\pel\PelEntry
$tag lsolesen\pel\PelTag 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.
Результат lsolesen\pel\PelEntry the entry.

offsetSet() публичный Метод

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: $ifd[PelTag::EXPOSURE_BIAS_VALUE] = $entry; Note that the actual array index passed is ignored! Instead the {@link PelTag} from the entry is used.
public offsetSet ( lsolesen\pel\PelTag $tag, lsolesen\pel\PelEntry $e )
$tag lsolesen\pel\PelTag the offset to update.
$e lsolesen\pel\PelEntry the new value.

offsetUnset() публичный Метод

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: unset($ifd[PelTag::EXPOSURE_BIAS_VALUE])
public offsetUnset ( lsolesen\pel\PelTag $tag )
$tag lsolesen\pel\PelTag the offset to delete.

setNextIfd() публичный Метод

Make this directory point to a new directory.
public setNextIfd ( PelIfd $i )
$i PelIfd the IFD that this directory will point to.

setThumbnail() публичный Метод

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