source: extensions/AMetaData/JpegMetaData/Readers/CanonReader.class.php @ 4904

Last change on this file since 4904 was 4904, checked in by grum, 14 years ago

Optimize some memory leak and some bugged lines of code

  • Property svn:executable set to *
File size: 4.6 KB
Line 
1<?php
2/*
3 * --:: JPEG MetaDatas ::-------------------------------------------------------
4 *
5 *  Author    : Grum
6 *   email    : grum at piwigo.org
7 *   website  : http://photos.grum.fr
8 *
9 *   << May the Little SpaceFrog be with you ! >>
10 *
11 *
12 * +-----------------------------------------------------------------------+
13 * | JpegMetaData - a PHP based Jpeg Metadata manager                      |
14 * +-----------------------------------------------------------------------+
15 * | Copyright(C) 2010  Grum - http://www.grum.fr                          |
16 * +-----------------------------------------------------------------------+
17 * | This program is free software; you can redistribute it and/or modify  |
18 * | it under the terms of the GNU General Public License as published by  |
19 * | the Free Software Foundation                                          |
20 * |                                                                       |
21 * | This program is distributed in the hope that it will be useful, but   |
22 * | WITHOUT ANY WARRANTY; without even the implied warranty of            |
23 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
24 * | General Public License for more details.                              |
25 * |                                                                       |
26 * | You should have received a copy of the GNU General Public License     |
27 * | along with this program; if not, write to the Free Software           |
28 * | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
29 * | USA.                                                                  |
30 * +-----------------------------------------------------------------------+
31 *
32 *
33 * -----------------------------------------------------------------------------
34 *
35 * The CanonReader class is the dedicated to read the specific Canon tags
36 *
37 * ====> See MakerNotesReader.class.php to know more about the structure <======
38 *
39 * -----------------------------------------------------------------------------
40 *
41 * .. Notes ..
42 *
43 *
44 * The CanonReader class is derived from the MakerNotesReader class.
45 *
46 * =====> See MakerNotesReader.class.php to know more about common methods <====
47 *
48 * -----------------------------------------------------------------------------
49 */
50
51
52
53  require_once(JPEG_METADATA_DIR."TagDefinitions/CanonTags.class.php");
54  require_once(JPEG_METADATA_DIR."Readers/MakerNotesReader.class.php");
55
56  class CanonReader extends MakerNotesReader
57  {
58    /**
59     * The constructor needs, like the ancestor, the datas to be parsed
60     *
61     * Some datas are offset on extra data, and this offset can be (some time)
62     * absolute inside the IFD, or relative. So, the offset of the IFD structure
63     * is needed
64     *
65     * The byte order can be different from the TIFF byte order !
66     *
67     * The constructor need the maker signature (see the MakerNotesSignatures
68     * class for a list of known signatures)
69     *
70     * @param String $data
71     * @param ULong $offset : offset of IFD block in the jpeg file
72     * @param String $byteOrder
73     * @param String $makerSignature :
74     */
75    function __construct($data, $offset, $byteOrder, $makerSignature)
76    {
77      /*
78       * Canon don't have signatures in his maker note, starting directly with
79       * the number of entries
80       */
81      $this->maker = MAKER_CANON;
82      $this->header = "";
83      $this->headerSize = 0;
84
85      parent::__construct($data, $offset, $byteOrder);
86    }
87
88    function __destruct()
89    {
90      parent::__destruct();
91    }
92
93
94    /**
95     * initialize the definition for Pentax exif tags
96     */
97    protected function initializeTagDef()
98    {
99      $this->tagDef = new CanonTags();
100    }
101
102    /**
103     * skip the IFD header
104     */
105    protected function skipHeader($headerSize=0)
106    {
107      parent::skipHeader($headerSize);
108    }
109
110    /**
111     * this function do the interpretation of specials tags
112     *
113     * the function return the interpreted value for the tag
114     *
115     * @param $tagId             : the id of the tag
116     * @param $values            : 'raw' value to be interpreted
117     * @param UByte $type        : if needed (for IFD structure) the type of data
118     * @param ULong $valueOffset : if needed, the offset of data in the jpeg file
119     * @return String or Array or DateTime or Integer or Float...
120     */
121    protected function processSpecialTag($tagId, $values, $type, $valuesOffset=0)
122    {
123      switch($tagId)
124      {
125        default:
126          $returned="Not yet implemented;".ConvertData::toHexDump($tagId, ByteType::USHORT)." => ".ConvertData::toHexDump($values, $type);
127          break;
128      }
129      return($returned);
130    }
131  }
132
133?>
Note: See TracBrowser for help on using the repository browser.