GetId3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //.
More...
GetId3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //.
module for analyzing GIF Image files
- Author
- James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g http://www.getid3.org
Definition at line 29 of file Gif.php.
◆ analyze()
GetId3\Module\Graphic\Gif::analyze |
( |
| ) |
|
- Returns
- boolean
Reimplemented from GetId3\Handler\BaseHandler.
Definition at line 36 of file Gif.php.
37 {
38 $info = &$this->getid3->info;
39
40 $info[
'fileformat'] =
'gif';
41 $info[
'video'][
'dataformat'] =
'gif';
42 $info[
'video'][
'lossless'] =
true;
43 $info[
'video'][
'pixel_aspect_ratio'] = (float) 1;
44
45 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
46 $GIFheader =
fread($this->getid3->fp, 13);
47 $offset = 0;
48
49 $info[
'gif'][
'header'][
'raw'][
'identifier'] = substr($GIFheader, $offset, 3);
50 $offset += 3;
51
52 $magic = 'GIF';
53 if (
$info[
'gif'][
'header'][
'raw'][
'identifier'] != $magic) {
54 $info[
'error'][] =
'Expecting "'.Helper::PrintHexBytes($magic).
'" at offset '.
$info[
'avdataoffset'].
', found "'.
Helper::PrintHexBytes(
$info[
'gif'][
'header'][
'raw'][
'identifier']).
'"';
55 unset(
$info[
'fileformat']);
57
58 return false;
59 }
60
61 $info[
'gif'][
'header'][
'raw'][
'version'] = substr($GIFheader, $offset, 3);
62 $offset += 3;
64 $offset += 2;
66 $offset += 2;
68 $offset += 1;
70 $offset += 1;
72 $offset += 1;
73
74 $info[
'video'][
'resolution_x'] =
$info[
'gif'][
'header'][
'raw'][
'width'];
75 $info[
'video'][
'resolution_y'] =
$info[
'gif'][
'header'][
'raw'][
'height'];
76 $info[
'gif'][
'version'] =
$info[
'gif'][
'header'][
'raw'][
'version'];
77 $info[
'gif'][
'header'][
'flags'][
'global_color_table'] = (bool) (
$info[
'gif'][
'header'][
'raw'][
'flags'] & 0x80);
78 if (
$info[
'gif'][
'header'][
'raw'][
'flags'] & 0x80) {
79
80 $info[
'gif'][
'header'][
'bits_per_pixel'] = 3 * (((
$info[
'gif'][
'header'][
'raw'][
'flags'] & 0x70) >> 4) + 1);
81 } else {
82 $info[
'gif'][
'header'][
'bits_per_pixel'] = 0;
83 }
84 $info[
'gif'][
'header'][
'flags'][
'global_color_sorted'] = (bool) (
$info[
'gif'][
'header'][
'raw'][
'flags'] & 0x40);
85 if (
$info[
'gif'][
'header'][
'flags'][
'global_color_table']) {
86
87
88 $info[
'gif'][
'header'][
'global_color_size'] = pow(2, (
$info[
'gif'][
'header'][
'raw'][
'flags'] & 0x07) + 1);
89 $info[
'video'][
'bits_per_sample'] = (
$info[
'gif'][
'header'][
'raw'][
'flags'] & 0x07) + 1;
90 } else {
91 $info[
'gif'][
'header'][
'global_color_size'] = 0;
92 }
93 if (
$info[
'gif'][
'header'][
'raw'][
'aspect_ratio'] != 0) {
94
95 $info[
'gif'][
'header'][
'aspect_ratio'] = (
$info[
'gif'][
'header'][
'raw'][
'aspect_ratio'] + 15) / 64;
96 }
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183 return true;
184 }
fseek($bytes, $whence=SEEK_SET)
static LittleEndian2Int($byteword, $signed=false)
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
References $info, GetId3\Handler\BaseHandler\fread(), GetId3\Handler\BaseHandler\fseek(), GetId3\Lib\Helper\LittleEndian2Int(), and GetId3\Lib\Helper\PrintHexBytes().
◆ GetLSBits()
GetId3\Module\Graphic\Gif::GetLSBits |
( |
|
$bits | ) |
|
@staticvar string $bitbuffer
- Parameters
-
- Returns
- type
Definition at line 192 of file Gif.php.
193 {
194 static $bitbuffer = '';
195 while (strlen($bitbuffer) < $bits) {
196 $bitbuffer = str_pad(decbin(ord(
fread($this->getid3->fp, 1))), 8,
'0', STR_PAD_LEFT).$bitbuffer;
197 }
198 $value = bindec(substr($bitbuffer, 0 - $bits));
199 $bitbuffer = substr($bitbuffer, 0, 0 - $bits);
200
201 return $value;
202 }
References GetId3\Handler\BaseHandler\fread().
The documentation for this class was generated from the following file:
- libs/composer/vendor/phansys/getid3/GetId3/Module/Graphic/Gif.php