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 for holding data of any kind.
45 * This class can hold bytes of undefined format.
47 * @author Martin Geisler <mgeisler@users.sourceforge.net>
50 class PelEntryUndefined extends PelEntry
54 * Make a new PelEntry that can hold undefined data.
57 * which this entry represents. This
58 * should be one of the constants defined in {@link PelTag},
59 * e.g., {@link PelTag::SCENE_TYPE}, {@link
60 * PelTag::MAKER_NOTE} or any other tag with format {@link
61 * PelFormat::UNDEFINED}.
64 * the data that this entry will be holding. Since
65 * the format is undefined, no checking will be done on the data. If no data are given, a empty string will be stored
67 public function __construct($tag, $data = '')
70 $this->format = PelFormat::UNDEFINED;
71 $this->setValue($data);
75 * Set the data of this undefined entry.
78 * the data that this entry will be holding. Since
79 * the format is undefined, no checking will be done on the data.
81 public function setValue($data)
83 $this->components = strlen($data);
88 * Get the data of this undefined entry.
90 * @return string the data that this entry is holding.
92 public function getValue()
98 * Get the value of this entry as text.
100 * The value will be returned in a format suitable for presentation.
103 * boolean some values can be returned in a long or more
104 * brief form, and this parameter controls that.
106 * @return string the value as text.
108 public function getText($brief = false)
110 switch ($this->tag) {
111 case PelTag::FILE_SOURCE:
112 // CC (e->components, 1, v);
113 switch (ord($this->bytes{0})) {
117 return sprintf('0x%02X', ord($this->bytes{0}));
120 case PelTag::SCENE_TYPE:
121 // CC (e->components, 1, v);
122 switch (ord($this->bytes{0})) {
124 return 'Directly photographed';
126 return sprintf('0x%02X', ord($this->bytes{0}));
129 case PelTag::COMPONENTS_CONFIGURATION:
130 // CC (e->components, 4, v);
132 for ($i = 0; $i < 4; $i ++) {
133 switch (ord($this->bytes{$i})) {
165 case PelTag::MAKER_NOTE:
166 // TODO: handle maker notes.
167 return $this->components . ' bytes unknown MakerNote data';
170 return '(undefined)';