4 * PEL: PHP Exif Library.
5 * A library with support for reading and
6 * writing all Exif headers in JPEG and TIFF images using PHP.
8 * Copyright (C) 2004, 2005 Martin Geisler.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program in the file COPYING; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
25 namespace lsolesen\pel;
28 * Classes used to hold data for Exif tags of format undefined.
30 * This file contains the base class {@link PelEntryUndefined} and
31 * the subclasses {@link PelEntryUserComment} which should be used
32 * to manage the {@link PelTag::USER_COMMENT} tag, and {@link
33 * PelEntryVersion} which is used to manage entries with version
36 * @author Martin Geisler <mgeisler@users.sourceforge.net>
37 * @license http://www.gnu.org/licenses/gpl.html GNU General Public
43 * Class to hold version information.
45 * There are three Exif entries that hold version information: the
46 * {@link PelTag::EXIF_VERSION}, {@link
47 * PelTag::FLASH_PIX_VERSION}, and {@link
48 * PelTag::INTEROPERABILITY_VERSION} tags. This class manages
51 * The class is used in a very straight-forward way:
53 * $entry = new PelEntryVersion(PelTag::EXIF_VERSION, 2.2);
55 * This creates an entry for an file complying to the Exif 2.2
56 * standard. It is easy to test for standards level of an unknown
59 * if ($entry->getTag() == PelTag::EXIF_VERSION &&
60 * $entry->getValue() > 2.0) {
61 * echo 'Recent Exif version.';
65 * @author Martin Geisler <mgeisler@users.sourceforge.net>
68 class PelEntryVersion extends PelEntry
72 * The version held by this entry.
79 * Make a new entry for holding a version.
82 * This should be one of {@link
83 * PelTag::EXIF_VERSION}, {@link PelTag::FLASH_PIX_VERSION},
84 * or {@link PelTag::INTEROPERABILITY_VERSION}.
86 * @param float $version
87 * The size of the entries leave room for
88 * exactly four digits: two digits on either side of the decimal
91 public function __construct($tag, $version = 0.0)
94 $this->format = PelFormat::UNDEFINED;
95 $this->setValue($version);
99 * Set the version held by this entry.
101 * @param float $version
102 * The size of the entries leave room for
103 * exactly four digits: two digits on either side of the decimal
106 public function setValue($version = 0.0)
108 $this->version = $version;
109 $major = floor($version);
110 $minor = ($version - $major) * 100;
111 $strValue = sprintf('%02.0f%02.0f', $major, $minor);
112 $this->components = strlen($strValue);
113 $this->bytes = $strValue;
117 * Return the version held by this entry.
119 * @return float This will be the same as the value
120 * given to {@link setValue} or {@link __construct the
123 public function getValue()
125 return $this->version;
129 * Return a text string with the version.
131 * @param boolean $brief
132 * controls if the output should be brief. Brief
133 * output omits the word 'Version' so the result is just 'Exif x.y'
134 * instead of 'Exif Version x.y' if the entry holds information
135 * about the Exif version --- the output for FlashPix is similar.
137 * @return string the version number with the type of the tag,
138 * either 'Exif' or 'FlashPix'.
140 public function getText($brief = false)
145 * Versions numbers like 2.0 would be output as just 2 if we don't
146 * add the '.0' ourselves.
148 if (floor($this->version) == $this->version) {
152 switch ($this->tag) {
153 case PelTag::EXIF_VERSION:
155 return Pel::fmt('Exif %s', $v);
157 return Pel::fmt('Exif Version %s', $v);
160 case PelTag::FLASH_PIX_VERSION:
162 return Pel::fmt('FlashPix %s', $v);
164 return Pel::fmt('FlashPix Version %s', $v);
167 case PelTag::INTEROPERABILITY_VERSION:
169 return Pel::fmt('Interoperability %s', $v);
171 return Pel::fmt('Interoperability Version %s', $v);
179 return Pel::fmt('Version %s', $v);