Source for file PelFormat.php

Documentation is available at PelFormat.php

  1. <?php
  2.  
  3. /* PEL: PHP EXIF Library. A library with support for reading and
  4. * writing all EXIF headers in JPEG and TIFF images using PHP.
  5. *
  6. * Copyright (C) 2004 Martin Geisler <gimpster@users.sourceforge.net>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program in the file COPYING; if not, write to the
  20. * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  21. * Boston, MA 02111-1307 USA
  22. */
  23.  
  24. /* PelFormat.php,v 1.7 2004/06/26 20:39:10 gimpster Exp */
  25.  
  26.  
  27. /**
  28. * Namespace for functions operating on EXIF formats.
  29. *
  30. * @author Martin Geisler <gimpster@users.sourceforge.net>
  31. * @version 1.7
  32. * @date 2004/06/26 20:39:10
  33. * @license http://www.gnu.org/licenses/gpl.html GNU General Public
  34. * License (GPL)
  35. * @package PEL
  36. */
  37.  
  38. /**
  39. * Namespace for functions operating on EXIF formats.
  40. *
  41. * This class defines the constants that are to be used whenever one
  42. * has to refer to the format of an EXIF tag. They will be
  43. * collectively denoted by the pseudo-type PelFormat throughout
  44. * the documentation.
  45. *
  46. * All the methods defined here are static, and they all operate on a
  47. * single argument which should be one of the class constants.
  48. *
  49. * @author Martin Geisler <gimpster@users.sourceforge.net>
  50. * @package PEL
  51. */
  52. class PelFormat {
  53.  
  54. /**
  55. * Unsigned byte.
  56. *
  57. * Each component will be an unsigned 8-bit integer with a value
  58. * between 0 and 255.
  59. */
  60. const BYTE = 1;
  61. /**
  62. * ASCII string
  63. *
  64. * Each component will be an ASCII character.
  65. */
  66. const ASCII = 2;
  67. /**
  68. * Unsigned short.
  69. *
  70. * Each component will be an unsigned 16-bit integer with a value
  71. * between 0 and 65535.
  72. */
  73. const SHORT = 3;
  74.  
  75. /**
  76. * Unsigned long.
  77. *
  78. * Each component will be an unsigned 32-bit integer with a value
  79. * between 0 and 4294967295.
  80. */
  81. const LONG = 4;
  82.  
  83. /**
  84. * Unsigned rational number.
  85. *
  86. * Each component will consist of two unsigned 32-bit integers
  87. * denoting the enumerator and denominator. Each integer will have
  88. * a value between 0 and 4294967295.
  89. */
  90. const RATIONAL = 5;
  91.  
  92. /**
  93. * Signed byte.
  94. *
  95. * Each component will be a signed 8-bit integer with a value
  96. * between -128 and 127.
  97. */
  98. const SBYTE = 6;
  99.  
  100. /**
  101. * Undefined byte.
  102. *
  103. * Each component will be a byte with no associated interpretation.
  104. */
  105. const UNDEFINED = 7;
  106.  
  107. /**
  108. * Signed short.
  109. *
  110. * Each component will be a signed 16-bit integer with a value
  111. * between -32768 and 32767.
  112. */
  113. const SSHORT = 8;
  114.  
  115. /**
  116. * Signed long.
  117. *
  118. * Each component will be a signed 32-bit integer with a value
  119. * between -2147483648 and 2147483647.
  120. */
  121. const SLONG = 9;
  122.  
  123. /**
  124. * Signed rational number.
  125. *
  126. * Each component will consist of two signed 32-bit integers
  127. * denoting the enumerator and denominator. Each integer will have
  128. * a value between -2147483648 and 2147483647.
  129. */
  130. const SRATIONAL = 10;
  131.  
  132. /** Floating point number. */
  133.  
  134. const FLOAT = 11;
  135.  
  136. /** Double precision floating point number. */
  137.  
  138. const DOUBLE = 12;
  139.  
  140.  
  141. /**
  142. * Returns the name of a format.
  143. *
  144. * @param PelFormat the format.
  145. *
  146. * @return string the name of the format, e.g., 'Ascii' for the
  147. * {@link ASCII} format etc.
  148. */
  149. static function getName($type) {
  150. switch ($type) {
  151. case self::ASCII: return 'Ascii';
  152. case self::BYTE: return 'Byte';
  153. case self::SHORT: return 'Short';
  154. case self::LONG: return 'Long';
  155. case self::RATIONAL: return 'Rational';
  156. case self::SBYTE: return 'SByte';
  157. case self::SSHORT: return 'SShort';
  158. case self::SLONG: return 'SLong';
  159. case self::SRATIONAL: return 'SRational';
  160. case self::FLOAT: return 'Float';
  161. case self::DOUBLE: return 'Double';
  162. case self::UNDEFINED: return 'Undefined';
  163. default: return Pel::fmt('Unknown format: 0x%X', $type);
  164. }
  165. }
  166.  
  167.  
  168. /**
  169. * Return the size of components in a given format.
  170. *
  171. * @param PelFormat the format.
  172. *
  173. * @return the size in bytes needed to store one component with the
  174. * given format.
  175. */
  176. static function getSize($type) {
  177. switch ($type) {
  178. case self::ASCII: return 1;
  179. case self::BYTE: return 1;
  180. case self::SHORT: return 2;
  181. case self::LONG: return 4;
  182. case self::RATIONAL: return 8;
  183. case self::SBYTE: return 1;
  184. case self::SSHORT: return 2;
  185. case self::SLONG: return 4;
  186. case self::SRATIONAL: return 8;
  187. case self::FLOAT: return 4;
  188. case self::DOUBLE: return 8;
  189. case self::UNDEFINED: return 1;
  190. default: return Pel::fmt('Unknown format: 0x%X', $type);
  191. }
  192. }
  193.  
  194. }
  195. ?>

SourceForge.net Logo Documentation generated on Wed, 21 Jul 2004 19:13:09 +0200 by phpDocumentor 1.3.0RC3