Source for file PelEntry.php
Documentation is available at PelEntry.php
/* PEL: PHP Exif Library. A library with support for reading and
* writing all Exif headers in JPEG and TIFF images using PHP.
* Copyright (C) 2004, 2005, 2006 Martin Geisler.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
* Classes for dealing with Exif entries.
* This file defines two exception classes and the abstract class
* {@link PelEntry} which provides the basic methods that all Exif
* entries will have. All Exif entries will be represented by
* descendants of the {@link PelEntry} class --- the class itself is
* abstract and so it cannot be instantiated.
* @author Martin Geisler <mgeisler@users.sourceforge.net>
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
/**#@+ Required class definitions. */
require_once('PelException.php');
require_once('PelFormat.php');
require_once('PelTag.php');
* Exception indicating a problem with an entry.
* @author Martin Geisler <mgeisler@users.sourceforge.net>
* The IFD type (if known).
* The tag of the entry (if known).
* Get the IFD type associated with the exception.
* @return int one of {@link PelIfd::IFD0}, {@link PelIfd::IFD1},
* {@link PelIfd::EXIF}, {@link PelIfd::GPS}, or {@link }
* PelIfd::INTEROPERABILITY}. If no type is set, null is returned.
* Get the tag associated with the exception.
* @return PelTag the tag. If no tag is set, null is returned.
* Exception indicating that an unexpected format was found.
* The documentation for each tag in {@link PelTag} will detail any
* @author Martin Geisler <mgeisler@users.sourceforge.net>
* Construct a new exception indicating an invalid format.
* @param int the type of IFD.
* @param PelTag the tag for which the violation was found.
* @param PelFormat the format found.
* @param PelFormat the expected format.
parent::__construct('Unexpected format found for %s tag: PelFormat::%s. ' .
'Expected PelFormat::%s instead.',
* Exception indicating that an unexpected number of components was
* Some tags have strict limits as to the allowed number of
* components, and this exception is thrown if the data violates such
* a constraint. The documentation for each tag in {@link PelTag}
* explains the expected number of components.
* @author Martin Geisler <mgeisler@users.sourceforge.net>
* Construct a new exception indicating a wrong number of
* @param int the type of IFD.
* @param PelTag the tag for which the violation was found.
* @param int the number of components found.
* @param int the expected number of components.
parent::__construct('Wrong number of components found for %s tag: %d. ' .
* Common ancestor class of all {@link PelIfd} entries.
* As this class is abstract you cannot instantiate objects from it.
* It only serves as a common ancestor to define the methods common to
* all entries. The most important methods are {@link getValue()} and
* {@link setValue()}, both of which is abstract in this class. The
* descendants will give concrete implementations for them.
* If you have some data coming from an image (some raw bytes), then
* the static method {@link newFromData()} is helpful --- it will look
* at the data and give you a proper decendent of {@link PelEntry}
* If you instead want to have an entry for some data which take the
* form of an integer, a string, a byte, or some other PHP type, then
* don't use this class. You should instead create an object of the
* right subclass ({@link PelEntryShort} for short integers, {@link }
* PelEntryAscii} for strings, and so on) directly.
* @author Martin Geisler <mgeisler@users.sourceforge.net>
* Type of IFD containing this tag.
* This must be one of the constants defined in {@link PelIfd}:
* {@link PelIfd::IFD0} for the main image IFD, {@link PelIfd::IFD1}
* for the thumbnail image IFD, {@link PelIfd::EXIF} for the Exif
* sub-IFD, {@link PelIfd::GPS} for the GPS sub-IFD, or {@link }
* PelIfd::INTEROPERABILITY} for the interoperability sub-IFD.
* The bytes representing this entry.
* Subclasses must either override {@link getBytes()} or, if
* possible, maintain this property so that it always contains a
* true representation of the entry.
* The {@link PelTag} of this entry.
* The {@link PelFormat} of this entry.
* The number of components of this entry.
* Return the tag of this entry.
* @return PelTag the tag of this entry.
* Return the type of IFD which holds this entry.
* @return int one of the constants defined in {@link PelIfd}:
* {@link PelIfd::IFD0} for the main image IFD, {@link PelIfd::IFD1}
* for the thumbnail image IFD, {@link PelIfd::EXIF} for the Exif
* sub-IFD, {@link PelIfd::GPS} for the GPS sub-IFD, or {@link }
* PelIfd::INTEROPERABILITY} for the interoperability sub-IFD.
* @param int must be one of the constants defined in {@link }
* PelIfd}: {@link PelIfd::IFD0} for the main image IFD, {@link }
* PelIfd::IFD1} for the thumbnail image IFD, {@link PelIfd::EXIF}
* for the Exif sub-IFD, {@link PelIfd::GPS} for the GPS sub-IFD, or
* {@link PelIfd::INTEROPERABILITY} for the interoperability
* Return the format of this entry.
* @return PelFormat the format of this entry.
* Return the number of components of this entry.
* @return int the number of components of this entry.
* Turn this entry into bytes.
* @param PelByteOrder the desired byte order, which must be either
* {@link Convert::LITTLE_ENDIAN} or {@link Convert::BIG_ENDIAN}.
* @return string bytes representing this entry.
* Get the value of this entry as text.
* The value will be returned in a format suitable for presentation,
* e.g., rationals will be returned as 'x/y', ASCII strings will be
* returned as themselves etc.
* @param boolean some values can be returned in a long or more
* brief form, and this parameter controls that.
* @return string the value as text.
abstract function getText($brief =
false);
* Get the value of this entry.
* The value returned will generally be the same as the one supplied
* to the constructor or with {@link setValue()}. For a formatted
* version of the value, one should use {@link getText()} instead.
* @return mixed the unformatted value.
* Set the value of this entry.
* The value should be in the same format as for the constructor.
* @param mixed the new value.
/* This (fake) abstract method is here to make it possible for the
* documentation to refer to PelEntry::setValue().
* It cannot declared abstract in the proper PHP way, for then PHP
* wont allow subclasses to define it with two arguments (which is
* what PelEntryCopyright does).
* Turn this entry into a string.
* @return string a string representation of this entry. This is
$str =
Pel::fmt(" Tag: 0x%04X (%s)\n",
$str .=
Pel::fmt(" Format : %d (%s)\n",
Documentation generated on Thu, 05 May 2011 07:19:00 +0200 by phpDocumentor 1.4.3