3 * PEL: PHP Exif Library.
4 * A library with support for reading and
5 * writing all Exif headers in JPEG and TIFF images using PHP.
7 * Copyright (C) 2004, 2005 Martin Geisler.
8 * Copyright (C) 2017 Johannes Weberhofer.
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 * Namespace for functions operating on Exif formats.
30 * This class defines the constants that are to be used whenever one
31 * has to refer to the format of an Exif tag. They will be
32 * collectively denoted by the pseudo-type PelFormat throughout the
35 * All the methods defined here are static, and they all operate on a
36 * single argument which should be one of the class constants.
38 * @author Martin Geisler <mgeisler@users.sourceforge.net>
39 * @author Johannes Weberhofer <jweberhofer@weberhofer.at>
40 * @license http://www.gnu.org/licenses/gpl.html GNU General Public
51 * Each component will be an unsigned 8-bit integer with a value
54 * Modelled with the {@link PelEntryByte} class.
61 * Each component will be an ASCII character.
63 * Modelled with the {@link PelEntryAscii} class.
70 * Each component will be an unsigned 16-bit integer with a value
71 * between 0 and 65535.
73 * Modelled with the {@link PelEntryShort} class.
80 * Each component will be an unsigned 32-bit integer with a value
81 * between 0 and 4294967295.
83 * Modelled with the {@link PelEntryLong} class.
88 * Unsigned rational number.
90 * Each component will consist of two unsigned 32-bit integers
91 * denoting the enumerator and denominator. Each integer will have
92 * a value between 0 and 4294967295.
94 * Modelled with the {@link PelEntryRational} class.
101 * Each component will be a signed 8-bit integer with a value
102 * between -128 and 127.
104 * Modelled with the {@link PelEntrySByte} class.
111 * Each component will be a byte with no associated interpretation.
113 * Modelled with the {@link PelEntryUndefined} class.
120 * Each component will be a signed 16-bit integer with a value
121 * between -32768 and 32767.
123 * Modelled with the {@link PelEntrySShort} class.
130 * Each component will be a signed 32-bit integer with a value
131 * between -2147483648 and 2147483647.
133 * Modelled with the {@link PelEntrySLong} class.
138 * Signed rational number.
140 * Each component will consist of two signed 32-bit integers
141 * denoting the enumerator and denominator. Each integer will have
142 * a value between -2147483648 and 2147483647.
144 * Modelled with the {@link PelEntrySRational} class.
146 const SRATIONAL = 10;
149 * Floating point number.
151 * Entries with this format are not currently implemented.
156 * Double precision floating point number.
158 * Entries with this format are not currently implemented.
163 * Values for format's short names
165 protected static $formatName = array(
166 self::ASCII => 'Ascii',
167 self::BYTE => 'Byte',
168 self::SHORT => 'Short',
169 self::LONG => 'Long',
170 self::RATIONAL => 'Rational',
171 self::SBYTE => 'SByte',
172 self::SSHORT => 'SShort',
173 self::SLONG => 'SLong',
174 self::SRATIONAL => 'SRational',
175 self::FLOAT => 'Float',
176 self::DOUBLE => 'Double',
177 self::UNDEFINED => 'Undefined'
180 protected static $formatLength = array(
189 self::SRATIONAL => 8,
196 * Returns the name of a format like 'Ascii' for the {@link ASCII} format
198 * @param integer $type
199 * as defined in {@link PelFormat}
202 public static function getName($type)
204 if (array_key_exists($type, self::$formatName)) {
205 return self::$formatName[$type];
207 return Pel::fmt('Unknown format: 0x%X', $type);
212 * Return the size of components in a given format in bytes needed to store one component with the
215 * @param integer $type
216 * as defined in {@link PelFormat}
217 * @return integer|string
219 public static function getSize($type)
221 if (array_key_exists($type, self::$formatLength)) {
222 return self::$formatLength[$type];
224 return Pel::fmt('Unknown format: 0x%X', $type);