PHP Class lsolesen\pel\PelTiff

Exif data is actually an extension of the TIFF file format. TIFF images consist of a number of {@link PelIfd Image File Directories} (IFDs), each containing a number of {@link PelEntry entries}. The IFDs are linked to each other --- one can get hold of the first one with the {@link getIfd()} method. To parse a TIFF image for Exif data one would do: $tiff = new PelTiff($data); $ifd0 = $tiff->getIfd(); $exif = $ifd0->getSubIfd(PelIfd::EXIF); $ifd1 = $ifd0->getNextIfd(); Should one have some image data of an unknown type, then the {@link PelTiff::isValid()} function is handy: it will quickly test if the data could be valid TIFF data. The {@link PelJpeg::isValid()} function does the same for JPEG images.
Author: Martin Geisler ([email protected])
Datei anzeigen Open project: lsolesen/pel Class Usage Examples

Public Methods

Method Description
__construct ( $data = false ) Construct a new object for holding TIFF data.
__toString ( ) : string Return a string representation of this object.
getBytes ( PelByteOrder $order = PelConvert::LITTLE_ENDIAN ) : string Turn this object into bytes.
getIfd ( ) : PelIfd Return the first IFD.
isValid ( lsolesen\pel\PelDataWindow $d ) : boolean Check if data is valid TIFF data.
load ( lsolesen\pel\PelDataWindow $d ) Load TIFF data.
loadFile ( string $filename ) Load data from a file into a TIFF object.
setIfd ( PelIfd $ifd ) Set the first IFD.

Method Details

__construct() public method

The new object will be empty (with no {@link PelIfd}) unless an argument is given from which it can initialize itself. This can either be the filename of a TIFF image or a {@link PelDataWindow} object. Use {@link setIfd()} to explicitly set the IFD.
public __construct ( $data = false )

__toString() public method

Return a string representation of this object.
public __toString ( ) : string
return string a string describing this object. This is mostly useful for debugging.

getBytes() public method

TIFF images can have {@link PelConvert::LITTLE_ENDIAN little-endian} or {@link PelConvert::BIG_ENDIAN big-endian} byte order, and so this method takes an argument specifying that.
public getBytes ( PelByteOrder $order = PelConvert::LITTLE_ENDIAN ) : string
$order PelByteOrder the desired byte order of the TIFF data. This should be one of {@link PelConvert::LITTLE_ENDIAN} or {@link PelConvert::BIG_ENDIAN}.
return string the bytes representing this object.

getIfd() public method

Return the first IFD.
public getIfd ( ) : PelIfd
return PelIfd the first IFD contained in the TIFF data, if any. If there is no IFD null will be returned.

isValid() public static method

This will read just enough data from the data window to determine if the data could be a valid TIFF data. This means that the check is more like a heuristic than a rigorous check.
See also: PelJpeg::isValid()
public static isValid ( lsolesen\pel\PelDataWindow $d ) : boolean
$d lsolesen\pel\PelDataWindow the bytes that will be examined.
return boolean true if the data looks like valid TIFF data, false otherwise.

load() public method

The data given will be parsed and an internal tree representation will be built. If the data cannot be parsed correctly, a {@link PelInvalidDataException} is thrown, explaining the problem.
public load ( lsolesen\pel\PelDataWindow $d )
$d lsolesen\pel\PelDataWindow

loadFile() public method

Load data from a file into a TIFF object.
public loadFile ( string $filename )
$filename string the filename. This must be a readable file.

setIfd() public method

Set the first IFD.
public setIfd ( PelIfd $ifd )
$ifd PelIfd the new first IFD, which must be of type {@link PelIfd::IFD0}.