- Timestamp:
- Jan 17, 2010, 7:05:35 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AMetaData/JpegMetaData/Readers/TiffReader.class.php
r4686 r4698 9 9 * << May the Little SpaceFrog be with you ! >> 10 10 * 11 * ----------------------------------------------------------------------------- 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 * +-----------------------------------------------------------------------+ 12 31 * 13 32 * 14 33 * ----------------------------------------------------------------------------- 15 34 * 35 * The TiffReader class is the dedicated to read a TIFF structure 36 * 37 * A Tiff structure is formatted as this : 38 * - byte order : 2 bytes, "II" or "MM", indicates the byte order 39 * - header tag : 2 bytes, UShort equals 0x002a 40 * - first IFD offset : 4 bytes, ULong 41 * - IFDs : 42 * 43 * => See IfdReader.class.php & IfdEntryReader.class.php to know more on IFD <== 44 * 45 * ----------------------------------------------------------------------------- 46 * 47 * .. Notes .. 48 * 49 * 50 * The TiffReader class is derived from the SegmentReader class. 51 * 52 * ======> See SegmentReader.class.php to know more about common methods <====== 53 * 54 * 55 * This class provides theses public functions : 56 * - getNbIFDs 57 * - getIFDs 58 * - getIFD 59 * 16 60 * ----------------------------------------------------------------------------- 17 61 */ 62 18 63 19 64 require_once(JPEG_METADATA_DIR."Common/ConvertData.class.php"); … … 29 74 private $firstIFDOffset = 0; 30 75 76 /** 77 * The constructor need the Tiff block datas (given as a Data object) and 78 * offset of the TIFF block inside the jpeg file 79 * 80 * @param Data $data : 81 * @param ULong $offsetData (optional) : 82 */ 31 83 function __construct(Data $data, $offsetData=0) 32 84 { … … 48 100 49 101 $header=$this->data->readUShort(); 50 if($header==0x 2a)102 if($header==0x002a) 51 103 { 52 104 $this->isValid=true; … … 62 114 } 63 115 64 private function readData() 65 { 66 $nextIFD = $this->firstIFDOffset; 67 while($nextIFD!=0) 68 { 69 $this->data->seek($nextIFD); 70 $IFD = new IfdReader($this->data->readASCII(), $nextIFD, $this->byteOrder); 71 $this->IFDs[]=$IFD; 72 $nextIFD = $IFD->getNextIFDOffset(); 73 } 74 } 75 116 /** 117 * return the number of IFDs found in the Tiff block 118 * 119 * @return Integer 120 */ 76 121 public function getNbIFDs() 77 122 { … … 79 124 } 80 125 126 /** 127 * return an array of IFD found in the the Tiff block 128 * 129 * @return IFD[] 130 */ 81 131 public function getIFDs() 82 132 { … … 84 134 } 85 135 136 /** 137 * returns a specific IFD 138 * 139 * @param Integer $num : index of the needed IFD 140 * @return IFD 141 */ 86 142 public function getIFD($num) 87 143 { … … 91 147 return(null); 92 148 } 93 94 149 95 150 public function toString() … … 104 159 } 105 160 161 /** 162 * The readData function read IFDs from the Tiff block, and add them into 163 * the IFDs array 164 */ 165 private function readData() 166 { 167 $nextIFD = $this->firstIFDOffset; 168 /* 169 * while the next IFD offset is not zero, read the IFD at the designed 170 * offset 171 * 172 * the next IFD offset is given at the end of the last IFD read. 173 */ 174 while($nextIFD!=0) 175 { 176 $this->data->seek($nextIFD); 177 $IFD = new IfdReader($this->data->readASCII(), $nextIFD, $this->byteOrder); 178 $this->IFDs[]=$IFD; 179 $nextIFD = $IFD->getNextIFDOffset(); 180 } 181 } 106 182 } 107 183
Note: See TracChangeset
for help on using the changeset viewer.