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 a user comment.
45 * This class is used to hold user comments, which can come in several
46 * different character encodings. The Exif standard specifies a
47 * certain format of the {@link PelTag::USER_COMMENT user comment
48 * tag}, and this class will make sure that the format is kept.
50 * The most basic use of this class simply stores an ASCII encoded
51 * string for later retrieval using {@link getValue}:
54 * $entry = new PelEntryUserComment('An ASCII string');
55 * echo $entry->getValue();
58 * The string can be encoded with a different encoding, and if so, the
59 * encoding must be given using the second argument. The Exif
60 * standard specifies three known encodings: 'ASCII', 'JIS', and
61 * 'Unicode'. If the user comment is encoded using a character
62 * encoding different from the tree known encodings, then the empty
63 * string should be passed as encoding, thereby specifying that the
64 * encoding is undefined.
66 * @author Martin Geisler <mgeisler@users.sourceforge.net>
69 class PelEntryUserComment extends PelEntryUndefined
82 * This should be one of 'ASCII', 'JIS', 'Unicode', or ''.
89 * Make a new entry for holding a user comment.
92 * string the new user comment.
95 * string the encoding of the comment. This should be either
96 * 'ASCII', 'JIS', 'Unicode', or the empty string specifying an
99 public function __construct($comment = '', $encoding = 'ASCII')
101 parent::__construct(PelTag::USER_COMMENT);
102 $this->setValue($comment, $encoding);
106 * Set the user comment.
109 * string the new user comment.
112 * string the encoding of the comment. This should be either
113 * 'ASCII', 'JIS', 'Unicode', or the empty string specifying an
116 public function setValue($comment = '', $encoding = 'ASCII')
118 $this->comment = $comment;
119 $this->encoding = $encoding;
120 parent::setValue(str_pad($encoding, 8, chr(0)) . $comment);
124 * Returns the user comment.
126 * The comment is returned with the same character encoding as when
127 * it was set using {@link setValue} or {@link __construct the
130 * @return string the user comment.
132 public function getValue()
134 return $this->comment;
138 * Returns the encoding.
140 * @return string the encoding of the user comment.
142 public function getEncoding()
144 return $this->encoding;
148 * Returns the user comment.
150 * @return string the user comment.
152 public function getText($brief = false)
154 return $this->comment;