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 ASCII strings.
30 * The classes defined here are to be used for Exif entries holding
31 * ASCII strings, such as {@link PelTag::MAKE}, {@link
32 * PelTag::SOFTWARE}, and {@link PelTag::DATE_TIME}. For
33 * entries holding normal textual ASCII strings the class {@link
34 * PelEntryAscii} should be used, but for entries holding
35 * timestamps the class {@link PelEntryTime} would be more
36 * convenient instead. Copyright information is handled by the {@link
37 * PelEntryCopyright} class.
39 * @author Martin Geisler <mgeisler@users.sourceforge.net>
40 * @license http://www.gnu.org/licenses/gpl.html GNU General Public
46 * Class for holding a plain ASCII string.
48 * This class can hold a single ASCII string, and it will be used as in
50 * $entry = $ifd->getEntry(PelTag::IMAGE_DESCRIPTION);
51 * print($entry->getValue());
52 * $entry->setValue('This is my image. I like it.');
55 * @author Martin Geisler <mgeisler@users.sourceforge.net>
58 class PelEntryAscii extends PelEntry
62 * The string hold by this entry.
64 * This is the string that was given to the {@link __construct
65 * constructor} or later to {@link setValue}, without any final NULL
73 * Make a new PelEntry that can hold an ASCII string.
76 * the tag which this entry represents. This should be
77 * one of the constants defined in {@link PelTag}, e.g., {@link
78 * PelTag::IMAGE_DESCRIPTION}, {@link PelTag::MODEL}, or any other
79 * tag with format {@link PelFormat::ASCII}.
82 * the string that this entry will represent. The
83 * string must obey the same rules as the string argument to {@link
84 * setValue}, namely that it should be given without any trailing
85 * NULL character and that it must be plain 7-bit ASCII.
87 public function __construct($tag, $str = '')
90 $this->format = PelFormat::ASCII;
95 * Give the entry a new ASCII value.
97 * This will overwrite the previous value. The value can be
98 * retrieved later with the {@link getValue} method.
101 * string the new value of the entry. This should be given
102 * without any trailing NULL character. The string must be plain
103 * 7-bit ASCII, the string should contain no high bytes.
105 * @todo Implement check for high bytes?
107 public function setValue($str)
109 $this->components = strlen($str) + 1;
111 $this->bytes = $str . chr(0x00);
115 * Return the ASCII string of the entry.
117 * @return string the string held, without any final NULL character.
118 * The string will be the same as the one given to {@link setValue}
119 * or to the {@link __construct constructor}.
121 public function getValue()
127 * Return the ASCII string of the entry.
129 * This methods returns the same as {@link getValue}.
132 * boolean not used with ASCII entries.
134 * @return string the string held, without any final NULL character.
135 * The string will be the same as the one given to {@link setValue}
136 * or to the {@link __construct constructor}.
138 public function getText($brief = false)