38 $info = &$this->getid3->info;
40 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
41 $TIFFheader =
fread($this->getid3->fp, 4);
43 switch (substr($TIFFheader, 0, 2)) {
45 $info[
'tiff'][
'byte_order'] =
'Intel';
48 $info[
'tiff'][
'byte_order'] =
'Motorola';
51 $info[
'error'][] =
'Invalid TIFF byte order identifier ('.substr($TIFFheader, 0, 2).
') at offset '.
$info[
'avdataoffset'];
57 $info[
'fileformat'] =
'tiff';
58 $info[
'video'][
'dataformat'] =
'tiff';
59 $info[
'video'][
'lossless'] =
true;
61 $CurrentIFD =
array();
63 $FieldTypeByteLength =
array(1=>1, 2=>1, 3=>2, 4=>4, 5=>8);
67 while ($nextIFDoffset > 0) {
69 $CurrentIFD[
'offset'] = $nextIFDoffset;
71 fseek($this->getid3->fp,
$info[
'avdataoffset'] + $nextIFDoffset, SEEK_SET);
74 for ($i = 0; $i < $CurrentIFD[
'fieldcount']; $i++) {
75 $CurrentIFD[
'fields'][$i][
'raw'][
'tag'] = $this->
TIFFendian2Int(
fread($this->getid3->fp, 2),
$info[
'tiff'][
'byte_order']);
76 $CurrentIFD[
'fields'][$i][
'raw'][
'type'] = $this->
TIFFendian2Int(
fread($this->getid3->fp, 2),
$info[
'tiff'][
'byte_order']);
77 $CurrentIFD[
'fields'][$i][
'raw'][
'length'] = $this->
TIFFendian2Int(
fread($this->getid3->fp, 4),
$info[
'tiff'][
'byte_order']);
78 $CurrentIFD[
'fields'][$i][
'raw'][
'offset'] =
fread($this->getid3->fp, 4);
80 switch ($CurrentIFD[
'fields'][$i][
'raw'][
'type']) {
82 if ($CurrentIFD[
'fields'][$i][
'raw'][
'length'] <= 4) {
83 $CurrentIFD[
'fields'][$i][
'value'] = $this->
TIFFendian2Int(substr($CurrentIFD[
'fields'][$i][
'raw'][
'offset'], 0, 1),
$info[
'tiff'][
'byte_order']);
85 $CurrentIFD[
'fields'][$i][
'offset'] = $this->
TIFFendian2Int($CurrentIFD[
'fields'][$i][
'raw'][
'offset'],
$info[
'tiff'][
'byte_order']);
90 if ($CurrentIFD[
'fields'][$i][
'raw'][
'length'] <= 4) {
91 $CurrentIFD[
'fields'][$i][
'value'] = substr($CurrentIFD[
'fields'][$i][
'raw'][
'offset'], 3);
93 $CurrentIFD[
'fields'][$i][
'offset'] = $this->
TIFFendian2Int($CurrentIFD[
'fields'][$i][
'raw'][
'offset'],
$info[
'tiff'][
'byte_order']);
98 if ($CurrentIFD[
'fields'][$i][
'raw'][
'length'] <= 2) {
99 $CurrentIFD[
'fields'][$i][
'value'] = $this->
TIFFendian2Int(substr($CurrentIFD[
'fields'][$i][
'raw'][
'offset'], 0, 2),
$info[
'tiff'][
'byte_order']);
101 $CurrentIFD[
'fields'][$i][
'offset'] = $this->
TIFFendian2Int($CurrentIFD[
'fields'][$i][
'raw'][
'offset'],
$info[
'tiff'][
'byte_order']);
106 if ($CurrentIFD[
'fields'][$i][
'raw'][
'length'] <= 1) {
107 $CurrentIFD[
'fields'][$i][
'value'] = $this->
TIFFendian2Int($CurrentIFD[
'fields'][$i][
'raw'][
'offset'],
$info[
'tiff'][
'byte_order']);
109 $CurrentIFD[
'fields'][$i][
'offset'] = $this->
TIFFendian2Int($CurrentIFD[
'fields'][$i][
'raw'][
'offset'],
$info[
'tiff'][
'byte_order']);
118 $info[
'tiff'][
'ifd'][] = $CurrentIFD;
119 $CurrentIFD =
array();
124 foreach (
$info[
'tiff'][
'ifd'] as $IFDid => $IFDarray) {
125 foreach ($IFDarray[
'fields'] as $key => $fieldarray) {
126 switch ($fieldarray[
'raw'][
'tag']) {
131 if (!isset($fieldarray[
'value'])) {
132 fseek($this->getid3->fp, $fieldarray[
'offset'], SEEK_SET);
133 $info[
'tiff'][
'ifd'][$IFDid][
'fields'][$key][
'raw'][
'data'] =
fread($this->getid3->fp, $fieldarray[
'raw'][
'length'] * $FieldTypeByteLength[$fieldarray[
'raw'][
'type']]);
145 if (isset($fieldarray[
'value'])) {
146 $info[
'tiff'][
'ifd'][$IFDid][
'fields'][$key][
'raw'][
'data'] = $fieldarray[
'value'];
148 fseek($this->getid3->fp, $fieldarray[
'offset'], SEEK_SET);
149 $info[
'tiff'][
'ifd'][$IFDid][
'fields'][$key][
'raw'][
'data'] =
fread($this->getid3->fp, $fieldarray[
'raw'][
'length'] * $FieldTypeByteLength[$fieldarray[
'raw'][
'type']]);
154 switch ($fieldarray[
'raw'][
'tag']) {
156 $info[
'video'][
'resolution_x'] = $fieldarray[
'value'];
160 $info[
'video'][
'resolution_y'] = $fieldarray[
'value'];
164 if (isset($fieldarray[
'value'])) {
165 $info[
'video'][
'bits_per_sample'] = $fieldarray[
'value'];
167 $info[
'video'][
'bits_per_sample'] = 0;
168 for ($i = 0; $i < $fieldarray[
'raw'][
'length']; $i++) {
169 $info[
'video'][
'bits_per_sample'] += $this->
TIFFendian2Int(substr(
$info[
'tiff'][
'ifd'][$IFDid][
'fields'][$key][
'raw'][
'data'], $i * $FieldTypeByteLength[$fieldarray[
'raw'][
'type']], $FieldTypeByteLength[$fieldarray[
'raw'][
'type']]),
$info[
'tiff'][
'byte_order']);
186 if (isset(
$info[
'tiff'][
'comments'][$TIFFcommentName])) {
187 $info[
'tiff'][
'comments'][$TIFFcommentName][] =
$info[
'tiff'][
'ifd'][$IFDid][
'fields'][$key][
'raw'][
'data'];
189 $info[
'tiff'][
'comments'][$TIFFcommentName] =
array(
$info[
'tiff'][
'ifd'][$IFDid][
'fields'][$key][
'raw'][
'data']);
210 if ($byteorder ==
'Intel') {
212 } elseif ($byteorder ==
'Motorola') {
227 static $TIFFcompressionMethod =
array();
228 if (empty($TIFFcompressionMethod)) {
229 $TIFFcompressionMethod =
array(
232 3 =>
'Fax - CCITT 3',
238 return (isset($TIFFcompressionMethod[$id]) ? $TIFFcompressionMethod[$id] :
'unknown/invalid ('.$id.
')');
249 static $TIFFcommentName =
array();
250 if (empty($TIFFcommentName)) {
251 $TIFFcommentName =
array(
252 270 =>
'imagedescription',
258 316 =>
'hostcomputer',
262 return (isset($TIFFcommentName[$id]) ? $TIFFcommentName[$id] :
'unknown/invalid ('.$id.
')');
GetId3() by James Heinrich info@getid3.org //.
GetId3() by James Heinrich info@getid3.org //.
TIFFendian2Int($bytestring, $byteorder)
TIFFcommentName($id)
array $TIFFcommentName
fseek($bytes, $whence=SEEK_SET)
TIFFcompressionMethod($id)
array $TIFFcompressionMethod
Create styles array
The data for the language used.
static LittleEndian2Int($byteword, $signed=false)
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)