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 copyright information.
48 * The Exif standard specifies a certain format for copyright
49 * information where the one {@link PelTag::COPYRIGHT copyright
50 * tag} holds both the photographer and editor copyrights, separated
51 * by a NULL character.
53 * This class is used to manipulate that tag so that the format is
54 * kept to the standard. A common use would be to add a new copyright
55 * tag to an image, since most cameras do not add this tag themselves.
56 * This would be done like this:
59 * $entry = new PelEntryCopyright('Copyright, Martin Geisler, 2004');
60 * $ifd0->addEntry($entry);
63 * Here we only set the photographer copyright, use the optional
64 * second argument to specify the editor copyright. If there is only
65 * an editor copyright, then let the first argument be the empty
68 * @author Martin Geisler <mgeisler@users.sourceforge.net>
71 class PelEntryCopyright extends PelEntryAscii
75 * The photographer copyright.
79 private $photographer;
82 * The editor copyright.
89 * Make a new entry for holding copyright information.
92 * string the photographer copyright. Use the empty string
93 * if there is no photographer copyright.
96 * string the editor copyright. Use the empty string if
97 * there is no editor copyright.
99 public function __construct($photographer = '', $editor = '')
101 parent::__construct(PelTag::COPYRIGHT);
102 $this->setValue($photographer, $editor);
106 * Update the copyright information.
109 * string the photographer copyright. Use the empty string
110 * if there is no photographer copyright.
113 * string the editor copyright. Use the empty string if
114 * there is no editor copyright.
116 public function setValue($photographer = '', $editor = '')
118 $this->photographer = $photographer;
119 $this->editor = $editor;
121 if ($photographer == '' && $editor != '') {
126 parent::setValue($photographer);
128 parent::setValue($photographer . chr(0x00) . $editor);
133 * Retrive the copyright information.
135 * The strings returned will be the same as the one used previously
136 * with either {@link __construct the constructor} or with {@link
139 * @return array an array with two strings, the photographer and
140 * editor copyrights. The two fields will be returned in that
141 * order, so that the first array index will be the photographer
142 * copyright, and the second will be the editor copyright.
144 public function getValue()
153 * Return a text string with the copyright information.
155 * The photographer and editor copyright fields will be returned
156 * with a '-' in between if both copyright fields are present,
157 * otherwise only one of them will be returned.
160 * boolean if false, then the strings '(Photographer)' and
161 * '(Editor)' will be appended to the photographer and editor
162 * copyright fields (if present), otherwise the fields will be
165 * @return string the copyright information in a string.
167 public function getText($brief = false)
173 $p = ' ' . Pel::tra('(Photographer)');
174 $e = ' ' . Pel::tra('(Editor)');
177 if ($this->photographer != '' && $this->editor != '') {
178 return $this->photographer . $p . ' - ' . $this->editor . $e;
181 if ($this->photographer != '') {
182 return $this->photographer . $p;
185 if ($this->editor != '') {
186 return $this->editor . $e;