22 $info = &$this->getid3->info;
25 $TIFFheader = $this->
fread(4);
27 switch (substr($TIFFheader, 0, 2)) {
29 $info[
'tiff'][
'byte_order'] =
'Intel';
32 $info[
'tiff'][
'byte_order'] =
'Motorola';
35 $this->
error(
'Invalid TIFF byte order identifier ('.substr($TIFFheader, 0, 2).
') at offset '.
$info[
'avdataoffset']);
40 $info[
'fileformat'] =
'tiff';
41 $info[
'video'][
'dataformat'] =
'tiff';
42 $info[
'video'][
'lossless'] =
true;
43 $info[
'tiff'][
'ifd'] = array();
44 $CurrentIFD = array();
46 $FieldTypeByteLength = array(1=>1, 2=>1, 3=>2, 4=>4, 5=>8);
50 while ($nextIFDoffset > 0) {
52 $CurrentIFD[
'offset'] = $nextIFDoffset;
54 $this->
fseek(
$info[
'avdataoffset'] + $nextIFDoffset);
57 for (
$i = 0;
$i < $CurrentIFD[
'fieldcount'];
$i++) {
61 $CurrentIFD[
'fields'][
$i][
'raw'][
'offset'] = $this->
fread(4);
63 switch ($CurrentIFD[
'fields'][
$i][
'raw'][
'type']) {
65 if ($CurrentIFD[
'fields'][$i][
'raw'][
'length'] <= 4) {
66 $CurrentIFD[
'fields'][
$i][
'value'] = $this->
TIFFendian2Int(substr($CurrentIFD[
'fields'][$i][
'raw'][
'offset'], 0, 1),
$info[
'tiff'][
'byte_order']);
68 $CurrentIFD[
'fields'][
$i][
'offset'] = $this->
TIFFendian2Int($CurrentIFD[
'fields'][$i][
'raw'][
'offset'],
$info[
'tiff'][
'byte_order']);
73 if ($CurrentIFD[
'fields'][$i][
'raw'][
'length'] <= 4) {
74 $CurrentIFD[
'fields'][
$i][
'value'] = substr($CurrentIFD[
'fields'][$i][
'raw'][
'offset'], 3);
76 $CurrentIFD[
'fields'][
$i][
'offset'] = $this->
TIFFendian2Int($CurrentIFD[
'fields'][$i][
'raw'][
'offset'],
$info[
'tiff'][
'byte_order']);
81 if ($CurrentIFD[
'fields'][$i][
'raw'][
'length'] <= 2) {
82 $CurrentIFD[
'fields'][
$i][
'value'] = $this->
TIFFendian2Int(substr($CurrentIFD[
'fields'][$i][
'raw'][
'offset'], 0, 2),
$info[
'tiff'][
'byte_order']);
84 $CurrentIFD[
'fields'][
$i][
'offset'] = $this->
TIFFendian2Int($CurrentIFD[
'fields'][$i][
'raw'][
'offset'],
$info[
'tiff'][
'byte_order']);
89 if ($CurrentIFD[
'fields'][$i][
'raw'][
'length'] <= 1) {
90 $CurrentIFD[
'fields'][
$i][
'value'] = $this->
TIFFendian2Int($CurrentIFD[
'fields'][$i][
'raw'][
'offset'],
$info[
'tiff'][
'byte_order']);
92 $CurrentIFD[
'fields'][
$i][
'offset'] = $this->
TIFFendian2Int($CurrentIFD[
'fields'][$i][
'raw'][
'offset'],
$info[
'tiff'][
'byte_order']);
101 $info[
'tiff'][
'ifd'][] = $CurrentIFD;
102 $CurrentIFD = array();
107 foreach (
$info[
'tiff'][
'ifd'] as $IFDid => $IFDarray) {
108 foreach ($IFDarray[
'fields'] as
$key => $fieldarray) {
109 switch ($fieldarray[
'raw'][
'tag']) {
114 if (!isset($fieldarray[
'value'])) {
115 $this->
fseek($fieldarray[
'offset']);
116 $info[
'tiff'][
'ifd'][$IFDid][
'fields'][
$key][
'raw'][
'data'] = $this->
fread($fieldarray[
'raw'][
'length'] * $FieldTypeByteLength[$fieldarray[
'raw'][
'type']]);
128 if (isset($fieldarray[
'value'])) {
129 $info[
'tiff'][
'ifd'][$IFDid][
'fields'][
$key][
'raw'][
'data'] = $fieldarray[
'value'];
131 $this->
fseek($fieldarray[
'offset']);
132 $info[
'tiff'][
'ifd'][$IFDid][
'fields'][
$key][
'raw'][
'data'] = $this->
fread($fieldarray[
'raw'][
'length'] * $FieldTypeByteLength[$fieldarray[
'raw'][
'type']]);
137 switch ($fieldarray[
'raw'][
'tag']) {
139 $info[
'video'][
'resolution_x'] = $fieldarray[
'value'];
143 $info[
'video'][
'resolution_y'] = $fieldarray[
'value'];
147 if (isset($fieldarray[
'value'])) {
148 $info[
'video'][
'bits_per_sample'] = $fieldarray[
'value'];
150 $info[
'video'][
'bits_per_sample'] = 0;
151 for (
$i = 0;
$i < $fieldarray[
'raw'][
'length'];
$i++) {
152 $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']);
169 if (isset(
$info[
'tiff'][
'comments'][$TIFFcommentName])) {
170 $info[
'tiff'][
'comments'][$TIFFcommentName][] =
$info[
'tiff'][
'ifd'][$IFDid][
'fields'][
$key][
'raw'][
'data'];
172 $info[
'tiff'][
'comments'][$TIFFcommentName] = array(
$info[
'tiff'][
'ifd'][$IFDid][
'fields'][
$key][
'raw'][
'data']);
187 if ($byteorder ==
'Intel') {
189 } elseif ($byteorder ==
'Motorola') {
196 static $TIFFcompressionMethod = array();
197 if (empty($TIFFcompressionMethod)) {
198 $TIFFcompressionMethod = array(
201 3 =>
'Fax - CCITT 3',
206 return (isset($TIFFcompressionMethod[
$id]) ? $TIFFcompressionMethod[$id] :
'unknown/invalid ('.$id.
')');
210 static $TIFFcommentName = array();
211 if (empty($TIFFcommentName)) {
212 $TIFFcommentName = array(
213 270 =>
'imagedescription',
219 316 =>
'hostcomputer',
222 return (isset($TIFFcommentName[
$id]) ? $TIFFcommentName[$id] :
'unknown/invalid ('.$id.
')');
TIFFendian2Int($bytestring, $byteorder)
if(!array_key_exists('StateId', $_REQUEST)) $id
static LittleEndian2Int($byteword, $signed=false)
TIFFcompressionMethod($id)
getID3() by James Heinrich info@getid3.org //
fseek($bytes, $whence=SEEK_SET)
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)