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, 2006, 2007 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 bytes, both signed and unsigned.
30 * PelEntryWindowsString} class is used to manipulate strings in the
31 * format Windows XP needs.
33 * @author Martin Geisler <mgeisler@users.sourceforge.net>
34 * @license http://www.gnu.org/licenses/gpl.html GNU General Public
40 * Class used to manipulate strings in the format Windows XP uses.
42 * When examining the file properties of an image in Windows XP one
43 * can fill in title, comment, author, keyword, and subject fields.
44 * Filling those fields and pressing OK will result in the data being
45 * written into the Exif data in the image.
47 * The data is written in a non-standard format and can thus not be
48 * loaded directly --- this class is needed to translate it into
51 * It is important that entries from this class are only created with
52 * the {@link PelTag::XP_TITLE}, {@link PelTag::XP_COMMENT}, {@link
53 * PelTag::XP_AUTHOR}, {@link PelTag::XP_KEYWORD}, and {@link
54 * PelTag::XP_SUBJECT} tags. If another tag is used the data will no
55 * longer be correctly decoded when reloaded with PEL. (The data will
56 * be loaded as an {@link PelEntryByte} entry, which isn't as useful.)
58 * This class is to be used as in
60 * $title = $ifd->getEntry(PelTag::XP_TITLE);
61 * print($title->getValue());
62 * $title->setValue('My favorite cat');
64 * or if no entry is present one can add a new one with
66 * $title = new PelEntryWindowsString(PelTag::XP_TITLE, 'A cute dog.');
67 * $ifd->addEntry($title);
70 * @author Martin Geisler <mgeisler@users.sourceforge.net>
73 class PelEntryWindowsString extends PelEntry
77 * The string hold by this entry.
79 * This is the string that was given to the {@link __construct
80 * constructor} or later to {@link setValue}, without any extra NULL
81 * characters or any such nonsense.
88 * Make a new PelEntry that can hold a Windows XP specific string.
91 * the tag which this entry represents. This should be
92 * one of {@link PelTag::XP_TITLE}, {@link PelTag::XP_COMMENT},
93 * {@link PelTag::XP_AUTHOR}, {@link PelTag::XP_KEYWORD}, and {@link
94 * PelTag::XP_SUBJECT} tags. If another tag is used, then this
95 * entry will be incorrectly reloaded as a {@link PelEntryByte}.
98 * the string that this entry will represent. It will
99 * be passed to {@link setValue} and thus has to obey its
102 public function __construct($tag, $str = '')
105 $this->format = PelFormat::BYTE;
106 $this->setValue($str);
110 * Give the entry a new value.
112 * This will overwrite the previous value. The value can be
113 * retrieved later with the {@link getValue} method.
116 * the new value of the entry. This should be use the
117 * Latin-1 encoding and be given without any extra NULL characters.
119 public function setValue($str)
123 $this->components = 2 * ($l + 1);
126 for ($i = 0; $i < $l; $i ++) {
127 $this->bytes .= $str{$i} . chr(0x00);
130 $this->bytes .= chr(0x00) . chr(0x00);
134 * Return the string of the entry.
136 * @return string the string held, without any extra NULL
137 * characters. The string will be the same as the one given to
138 * {@link setValue} or to the {@link __construct constructor}.
140 public function getValue()
146 * Return the string of the entry.
148 * This methods returns the same as {@link getValue}.
150 * @param boolean $brief
153 * @return string the string held, without any extra NULL
154 * characters. The string will be the same as the one given to
155 * {@link setValue} or to the {@link __construct constructor}.
157 public function getText($brief = false)