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, 2005  Martin Geisler.
  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., 51 Franklin St, Fifth Floor,
  21.  *  Boston, MA 02110-1301 USA
  22.  */
  23.  
  24. /* $Id$ */
  25.  
  26.  
  27. /**
  28.  * Namespace for functions operating on Exif formats.
  29.  *
  30.  * @author Martin Geisler <mgeisler@users.sourceforge.net>
  31.  * @version $Revision$
  32.  * @date $Date$
  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 the
  44.  * 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 <mgeisler@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.    * Modelled with the {@link PelEntryByte} class.
  61.    */
  62.   const BYTE       =  1;
  63.   
  64.   /**
  65.    * ASCII string.
  66.    *
  67.    * Each component will be an ASCII character.
  68.    *
  69.    * Modelled with the {@link PelEntryAscii} class.
  70.    */
  71.   const ASCII      =  2;
  72.   
  73.   /**
  74.    * Unsigned short.
  75.    *
  76.    * Each component will be an unsigned 16-bit integer with a value
  77.    * between 0 and 65535.
  78.    *
  79.    * Modelled with the {@link PelEntryShort} class.
  80.    */
  81.   const SHORT      =  3;
  82.  
  83.   /**
  84.    * Unsigned long.
  85.    *
  86.    * Each component will be an unsigned 32-bit integer with a value
  87.    * between 0 and 4294967295.
  88.    *
  89.    * Modelled with the {@link PelEntryLong} class.
  90.    */
  91.   const LONG       =  4;
  92.  
  93.   /**
  94.    * Unsigned rational number.
  95.    *
  96.    * Each component will consist of two unsigned 32-bit integers
  97.    * denoting the enumerator and denominator.  Each integer will have
  98.    * a value between 0 and 4294967295.
  99.    *
  100.    * Modelled with the {@link PelEntryRational} class.
  101.    */
  102.   const RATIONAL   =  5;
  103.  
  104.   /**
  105.    * Signed byte.
  106.    *
  107.    * Each component will be a signed 8-bit integer with a value
  108.    * between -128 and 127.
  109.    *
  110.    * Modelled with the {@link PelEntrySByte} class.
  111.    */
  112.   const SBYTE      =  6;
  113.  
  114.   /**
  115.    * Undefined byte.
  116.    *
  117.    * Each component will be a byte with no associated interpretation.
  118.    *
  119.    * Modelled with the {@link PelEntryUndefined} class.
  120.    */
  121.   const UNDEFINED  =  7;
  122.  
  123.   /**
  124.    * Signed short.
  125.    *
  126.    * Each component will be a signed 16-bit integer with a value
  127.    * between -32768 and 32767.
  128.    *
  129.    * Modelled with the {@link PelEntrySShort} class.
  130.    */
  131.   const SSHORT     =  8;
  132.  
  133.   /**
  134.    * Signed long.
  135.    *
  136.    * Each component will be a signed 32-bit integer with a value
  137.    * between -2147483648 and 2147483647.
  138.    *
  139.    * Modelled with the {@link PelEntrySLong} class.
  140.    */
  141.   const SLONG      =  9;
  142.  
  143.   /**
  144.    * Signed rational number.
  145.    *
  146.    * Each component will consist of two signed 32-bit integers
  147.    * denoting the enumerator and denominator.  Each integer will have
  148.    * a value between -2147483648 and 2147483647.
  149.    *
  150.    * Modelled with the {@link PelEntrySRational} class.
  151.    */
  152.   const SRATIONAL  10;
  153.  
  154.   /**
  155.    * Floating point number.
  156.    *
  157.    * Entries with this format are not currently implemented.
  158.    */
  159.   const FLOAT      11;
  160.  
  161.   /**
  162.    * Double precision floating point number.
  163.    *
  164.    * Entries with this format are not currently implemented.
  165.    */
  166.   const DOUBLE     12;
  167.  
  168.  
  169.   /**
  170.    * Returns the name of a format.
  171.    *
  172.    * @param PelFormat the format.
  173.    *
  174.    * @return string the name of the format, e.g., 'Ascii' for the
  175.    *  {@link ASCII} format etc.
  176.    */
  177.   static function getName($type{
  178.     switch ($type{
  179.     case self::ASCII:     return 'Ascii';
  180.     case self::BYTE:      return 'Byte';
  181.     case self::SHORT:     return 'Short';
  182.     case self::LONG:      return 'Long';
  183.     case self::RATIONAL:  return 'Rational';
  184.     case self::SBYTE:     return 'SByte';
  185.     case self::SSHORT:    return 'SShort';
  186.     case self::SLONG:     return 'SLong';
  187.     case self::SRATIONALreturn 'SRational';
  188.     case self::FLOAT:     return 'Float';
  189.     case self::DOUBLE:    return 'Double';
  190.     case self::UNDEFINEDreturn 'Undefined';
  191.     default:
  192.       return Pel::fmt('Unknown format: 0x%X'$type);
  193.     }
  194.   }
  195.  
  196.  
  197.   /**
  198.    * Return the size of components in a given format.
  199.    *
  200.    * @param PelFormat the format.
  201.    *
  202.    * @return the size in bytes needed to store one component with the
  203.    *  given format.
  204.    */
  205.   static function getSize($type{
  206.     switch ($type{
  207.     case self::ASCII:     return 1;
  208.     case self::BYTE:      return 1;
  209.     case self::SHORT:     return 2;
  210.     case self::LONG:      return 4;
  211.     case self::RATIONAL:  return 8;
  212.     case self::SBYTE:     return 1;
  213.     case self::SSHORT:    return 2;
  214.     case self::SLONG:     return 4;
  215.     case self::SRATIONALreturn 8;
  216.     case self::FLOAT:     return 4;
  217.     case self::DOUBLE:    return 8;
  218.     case self::UNDEFINEDreturn 1;
  219.     default:
  220.       return Pel::fmt('Unknown format: 0x%X'$type);
  221.     }
  222.   }
  223.  
  224. }
  225. ?>

Documentation generated on Thu, 05 May 2011 07:19:11 +0200 by phpDocumentor 1.4.3