ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
getid3_png Class Reference

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g // More...

+ Inheritance diagram for getid3_png:
+ Collaboration diagram for getid3_png:

Public Member Functions

 Analyze ()
 
 PNGsRGBintentLookup ($sRGB)
 
 PNGcompressionMethodLookup ($compressionmethod)
 
 PNGpHYsUnitLookup ($unitid)
 
 PNGoFFsUnitLookup ($unitid)
 
 PNGpCALequationTypeLookup ($equationtype)
 
 PNGsCALUnitLookup ($unitid)
 
 IHDRcalculateBitsPerSample ($color_type, $bit_depth)
 
- Public Member Functions inherited from getid3_handler
 __construct (getID3 $getid3, $call_module=null)
 
 Analyze ()
 
 AnalyzeString ($string)
 
 setStringMode ($string)
 
 saveAttachment ($name, $offset, $length, $image_mime=null)
 

Data Fields

 $max_data_bytes = 10000000
 

Additional Inherited Members

- Protected Member Functions inherited from getid3_handler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
 notice ($text)
 
- Protected Attributes inherited from getid3_handler
 $getid3
 
 $data_string_flag = false
 
 $data_string = ''
 
 $data_string_position = 0
 
 $data_string_length = 0
 

Detailed Description

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //

Definition at line 18 of file module.graphic.png.php.

Member Function Documentation

◆ Analyze()

getid3_png::Analyze ( )

Reimplemented from getid3_handler.

Definition at line 22 of file module.graphic.png.php.

22 {
23
24 $info = &$this->getid3->info;
25
26 // shortcut
27 $info['png'] = array();
28 $thisfile_png = &$info['png'];
29
30 $info['fileformat'] = 'png';
31 $info['video']['dataformat'] = 'png';
32 $info['video']['lossless'] = false;
33
34 $this->fseek($info['avdataoffset']);
35 $PNGfiledata = $this->fread($this->getid3->fread_buffer_size());
36 $offset = 0;
37
38 $PNGidentifier = substr($PNGfiledata, $offset, 8); // $89 $50 $4E $47 $0D $0A $1A $0A
39 $offset += 8;
40
41 if ($PNGidentifier != "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") {
42 $this->error('First 8 bytes of file ('.getid3_lib::PrintHexBytes($PNGidentifier).') did not match expected PNG identifier');
43 unset($info['fileformat']);
44 return false;
45 }
46
47 while ((($this->ftell() - (strlen($PNGfiledata) - $offset)) < $info['filesize'])) {
48 $chunk['data_length'] = getid3_lib::BigEndian2Int(substr($PNGfiledata, $offset, 4));
49 if ($chunk['data_length'] === false) {
50 $this->error('Failed to read data_length at offset '.$offset);
51 return false;
52 }
53 $offset += 4;
54 $truncated_data = false;
55 while (((strlen($PNGfiledata) - $offset) < ($chunk['data_length'] + 4)) && ($this->ftell() < $info['filesize'])) {
56 if (strlen($PNGfiledata) < $this->max_data_bytes) {
57 $PNGfiledata .= $this->fread($this->getid3->fread_buffer_size());
58 } else {
59 $this->warning('At offset '.$offset.' chunk "'.substr($PNGfiledata, $offset, 4).'" exceeded max_data_bytes value of '.$this->max_data_bytes.', data chunk will be truncated at '.(strlen($PNGfiledata) - 8).' bytes');
60 break;
61 }
62 }
63 $chunk['type_text'] = substr($PNGfiledata, $offset, 4);
64 $offset += 4;
65 $chunk['type_raw'] = getid3_lib::BigEndian2Int($chunk['type_text']);
66 $chunk['data'] = substr($PNGfiledata, $offset, $chunk['data_length']);
67 $offset += $chunk['data_length'];
68 $chunk['crc'] = getid3_lib::BigEndian2Int(substr($PNGfiledata, $offset, 4));
69 $offset += 4;
70
71 $chunk['flags']['ancilliary'] = (bool) ($chunk['type_raw'] & 0x20000000);
72 $chunk['flags']['private'] = (bool) ($chunk['type_raw'] & 0x00200000);
73 $chunk['flags']['reserved'] = (bool) ($chunk['type_raw'] & 0x00002000);
74 $chunk['flags']['safe_to_copy'] = (bool) ($chunk['type_raw'] & 0x00000020);
75
76 // shortcut
77 $thisfile_png[$chunk['type_text']] = array();
78 $thisfile_png_chunk_type_text = &$thisfile_png[$chunk['type_text']];
79
80 switch ($chunk['type_text']) {
81
82 case 'IHDR': // Image Header
83 $thisfile_png_chunk_type_text['header'] = $chunk;
84 $thisfile_png_chunk_type_text['width'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 4));
85 $thisfile_png_chunk_type_text['height'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 4, 4));
86 $thisfile_png_chunk_type_text['raw']['bit_depth'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 8, 1));
87 $thisfile_png_chunk_type_text['raw']['color_type'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 9, 1));
88 $thisfile_png_chunk_type_text['raw']['compression_method'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 10, 1));
89 $thisfile_png_chunk_type_text['raw']['filter_method'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 11, 1));
90 $thisfile_png_chunk_type_text['raw']['interlace_method'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 12, 1));
91
92 $thisfile_png_chunk_type_text['compression_method_text'] = $this->PNGcompressionMethodLookup($thisfile_png_chunk_type_text['raw']['compression_method']);
93 $thisfile_png_chunk_type_text['color_type']['palette'] = (bool) ($thisfile_png_chunk_type_text['raw']['color_type'] & 0x01);
94 $thisfile_png_chunk_type_text['color_type']['true_color'] = (bool) ($thisfile_png_chunk_type_text['raw']['color_type'] & 0x02);
95 $thisfile_png_chunk_type_text['color_type']['alpha'] = (bool) ($thisfile_png_chunk_type_text['raw']['color_type'] & 0x04);
96
97 $info['video']['resolution_x'] = $thisfile_png_chunk_type_text['width'];
98 $info['video']['resolution_y'] = $thisfile_png_chunk_type_text['height'];
99
100 $info['video']['bits_per_sample'] = $this->IHDRcalculateBitsPerSample($thisfile_png_chunk_type_text['raw']['color_type'], $thisfile_png_chunk_type_text['raw']['bit_depth']);
101 break;
102
103
104 case 'PLTE': // Palette
105 $thisfile_png_chunk_type_text['header'] = $chunk;
106 $paletteoffset = 0;
107 for ($i = 0; $i <= 255; $i++) {
108 //$thisfile_png_chunk_type_text['red'][$i] = getid3_lib::BigEndian2Int(substr($chunk['data'], $paletteoffset++, 1));
109 //$thisfile_png_chunk_type_text['green'][$i] = getid3_lib::BigEndian2Int(substr($chunk['data'], $paletteoffset++, 1));
110 //$thisfile_png_chunk_type_text['blue'][$i] = getid3_lib::BigEndian2Int(substr($chunk['data'], $paletteoffset++, 1));
111 $red = getid3_lib::BigEndian2Int(substr($chunk['data'], $paletteoffset++, 1));
112 $green = getid3_lib::BigEndian2Int(substr($chunk['data'], $paletteoffset++, 1));
113 $blue = getid3_lib::BigEndian2Int(substr($chunk['data'], $paletteoffset++, 1));
114 $thisfile_png_chunk_type_text[$i] = (($red << 16) | ($green << 8) | ($blue));
115 }
116 break;
117
118
119 case 'tRNS': // Transparency
120 $thisfile_png_chunk_type_text['header'] = $chunk;
121 switch ($thisfile_png['IHDR']['raw']['color_type']) {
122 case 0:
123 $thisfile_png_chunk_type_text['transparent_color_gray'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 2));
124 break;
125
126 case 2:
127 $thisfile_png_chunk_type_text['transparent_color_red'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 2));
128 $thisfile_png_chunk_type_text['transparent_color_green'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 2, 2));
129 $thisfile_png_chunk_type_text['transparent_color_blue'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 4, 2));
130 break;
131
132 case 3:
133 for ($i = 0; $i < strlen($chunk['data']); $i++) {
134 $thisfile_png_chunk_type_text['palette_opacity'][$i] = getid3_lib::BigEndian2Int(substr($chunk['data'], $i, 1));
135 }
136 break;
137
138 case 4:
139 case 6:
140 $this->error('Invalid color_type in tRNS chunk: '.$thisfile_png['IHDR']['raw']['color_type']);
141
142 default:
143 $this->warning('Unhandled color_type in tRNS chunk: '.$thisfile_png['IHDR']['raw']['color_type']);
144 break;
145 }
146 break;
147
148
149 case 'gAMA': // Image Gamma
150 $thisfile_png_chunk_type_text['header'] = $chunk;
151 $thisfile_png_chunk_type_text['gamma'] = getid3_lib::BigEndian2Int($chunk['data']) / 100000;
152 break;
153
154
155 case 'cHRM': // Primary Chromaticities
156 $thisfile_png_chunk_type_text['header'] = $chunk;
157 $thisfile_png_chunk_type_text['white_x'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 4)) / 100000;
158 $thisfile_png_chunk_type_text['white_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 4, 4)) / 100000;
159 $thisfile_png_chunk_type_text['red_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 8, 4)) / 100000;
160 $thisfile_png_chunk_type_text['red_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 12, 4)) / 100000;
161 $thisfile_png_chunk_type_text['green_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 16, 4)) / 100000;
162 $thisfile_png_chunk_type_text['green_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 20, 4)) / 100000;
163 $thisfile_png_chunk_type_text['blue_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 24, 4)) / 100000;
164 $thisfile_png_chunk_type_text['blue_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 28, 4)) / 100000;
165 break;
166
167
168 case 'sRGB': // Standard RGB Color Space
169 $thisfile_png_chunk_type_text['header'] = $chunk;
170 $thisfile_png_chunk_type_text['reindering_intent'] = getid3_lib::BigEndian2Int($chunk['data']);
171 $thisfile_png_chunk_type_text['reindering_intent_text'] = $this->PNGsRGBintentLookup($thisfile_png_chunk_type_text['reindering_intent']);
172 break;
173
174
175 case 'iCCP': // Embedded ICC Profile
176 $thisfile_png_chunk_type_text['header'] = $chunk;
177 list($profilename, $compressiondata) = explode("\x00", $chunk['data'], 2);
178 $thisfile_png_chunk_type_text['profile_name'] = $profilename;
179 $thisfile_png_chunk_type_text['compression_method'] = getid3_lib::BigEndian2Int(substr($compressiondata, 0, 1));
180 $thisfile_png_chunk_type_text['compression_profile'] = substr($compressiondata, 1);
181
182 $thisfile_png_chunk_type_text['compression_method_text'] = $this->PNGcompressionMethodLookup($thisfile_png_chunk_type_text['compression_method']);
183 break;
184
185
186 case 'tEXt': // Textual Data
187 $thisfile_png_chunk_type_text['header'] = $chunk;
188 list($keyword, $text) = explode("\x00", $chunk['data'], 2);
189 $thisfile_png_chunk_type_text['keyword'] = $keyword;
190 $thisfile_png_chunk_type_text['text'] = $text;
191
192 $thisfile_png['comments'][$thisfile_png_chunk_type_text['keyword']][] = $thisfile_png_chunk_type_text['text'];
193 break;
194
195
196 case 'zTXt': // Compressed Textual Data
197 $thisfile_png_chunk_type_text['header'] = $chunk;
198 list($keyword, $otherdata) = explode("\x00", $chunk['data'], 2);
199 $thisfile_png_chunk_type_text['keyword'] = $keyword;
200 $thisfile_png_chunk_type_text['compression_method'] = getid3_lib::BigEndian2Int(substr($otherdata, 0, 1));
201 $thisfile_png_chunk_type_text['compressed_text'] = substr($otherdata, 1);
202 $thisfile_png_chunk_type_text['compression_method_text'] = $this->PNGcompressionMethodLookup($thisfile_png_chunk_type_text['compression_method']);
203 switch ($thisfile_png_chunk_type_text['compression_method']) {
204 case 0:
205 $thisfile_png_chunk_type_text['text'] = gzuncompress($thisfile_png_chunk_type_text['compressed_text']);
206 break;
207
208 default:
209 // unknown compression method
210 break;
211 }
212
213 if (isset($thisfile_png_chunk_type_text['text'])) {
214 $thisfile_png['comments'][$thisfile_png_chunk_type_text['keyword']][] = $thisfile_png_chunk_type_text['text'];
215 }
216 break;
217
218
219 case 'iTXt': // International Textual Data
220 $thisfile_png_chunk_type_text['header'] = $chunk;
221 list($keyword, $otherdata) = explode("\x00", $chunk['data'], 2);
222 $thisfile_png_chunk_type_text['keyword'] = $keyword;
223 $thisfile_png_chunk_type_text['compression'] = (bool) getid3_lib::BigEndian2Int(substr($otherdata, 0, 1));
224 $thisfile_png_chunk_type_text['compression_method'] = getid3_lib::BigEndian2Int(substr($otherdata, 1, 1));
225 $thisfile_png_chunk_type_text['compression_method_text'] = $this->PNGcompressionMethodLookup($thisfile_png_chunk_type_text['compression_method']);
226 list($languagetag, $translatedkeyword, $text) = explode("\x00", substr($otherdata, 2), 3);
227 $thisfile_png_chunk_type_text['language_tag'] = $languagetag;
228 $thisfile_png_chunk_type_text['translated_keyword'] = $translatedkeyword;
229
230 if ($thisfile_png_chunk_type_text['compression']) {
231
232 switch ($thisfile_png_chunk_type_text['compression_method']) {
233 case 0:
234 $thisfile_png_chunk_type_text['text'] = gzuncompress($text);
235 break;
236
237 default:
238 // unknown compression method
239 break;
240 }
241
242 } else {
243
244 $thisfile_png_chunk_type_text['text'] = $text;
245
246 }
247
248 if (isset($thisfile_png_chunk_type_text['text'])) {
249 $thisfile_png['comments'][$thisfile_png_chunk_type_text['keyword']][] = $thisfile_png_chunk_type_text['text'];
250 }
251 break;
252
253
254 case 'bKGD': // Background Color
255 $thisfile_png_chunk_type_text['header'] = $chunk;
256 switch ($thisfile_png['IHDR']['raw']['color_type']) {
257 case 0:
258 case 4:
259 $thisfile_png_chunk_type_text['background_gray'] = getid3_lib::BigEndian2Int($chunk['data']);
260 break;
261
262 case 2:
263 case 6:
264 $thisfile_png_chunk_type_text['background_red'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0 * $thisfile_png['IHDR']['raw']['bit_depth'], $thisfile_png['IHDR']['raw']['bit_depth']));
265 $thisfile_png_chunk_type_text['background_green'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 1 * $thisfile_png['IHDR']['raw']['bit_depth'], $thisfile_png['IHDR']['raw']['bit_depth']));
266 $thisfile_png_chunk_type_text['background_blue'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 2 * $thisfile_png['IHDR']['raw']['bit_depth'], $thisfile_png['IHDR']['raw']['bit_depth']));
267 break;
268
269 case 3:
270 $thisfile_png_chunk_type_text['background_index'] = getid3_lib::BigEndian2Int($chunk['data']);
271 break;
272
273 default:
274 break;
275 }
276 break;
277
278
279 case 'pHYs': // Physical Pixel Dimensions
280 $thisfile_png_chunk_type_text['header'] = $chunk;
281 $thisfile_png_chunk_type_text['pixels_per_unit_x'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 4));
282 $thisfile_png_chunk_type_text['pixels_per_unit_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 4, 4));
283 $thisfile_png_chunk_type_text['unit_specifier'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 8, 1));
284 $thisfile_png_chunk_type_text['unit'] = $this->PNGpHYsUnitLookup($thisfile_png_chunk_type_text['unit_specifier']);
285 break;
286
287
288 case 'sBIT': // Significant Bits
289 $thisfile_png_chunk_type_text['header'] = $chunk;
290 switch ($thisfile_png['IHDR']['raw']['color_type']) {
291 case 0:
292 $thisfile_png_chunk_type_text['significant_bits_gray'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 1));
293 break;
294
295 case 2:
296 case 3:
297 $thisfile_png_chunk_type_text['significant_bits_red'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 1));
298 $thisfile_png_chunk_type_text['significant_bits_green'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 1, 1));
299 $thisfile_png_chunk_type_text['significant_bits_blue'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 2, 1));
300 break;
301
302 case 4:
303 $thisfile_png_chunk_type_text['significant_bits_gray'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 1));
304 $thisfile_png_chunk_type_text['significant_bits_alpha'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 1, 1));
305 break;
306
307 case 6:
308 $thisfile_png_chunk_type_text['significant_bits_red'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 1));
309 $thisfile_png_chunk_type_text['significant_bits_green'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 1, 1));
310 $thisfile_png_chunk_type_text['significant_bits_blue'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 2, 1));
311 $thisfile_png_chunk_type_text['significant_bits_alpha'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 3, 1));
312 break;
313
314 default:
315 break;
316 }
317 break;
318
319
320 case 'sPLT': // Suggested Palette
321 $thisfile_png_chunk_type_text['header'] = $chunk;
322 list($palettename, $otherdata) = explode("\x00", $chunk['data'], 2);
323 $thisfile_png_chunk_type_text['palette_name'] = $palettename;
324 $sPLToffset = 0;
325 $thisfile_png_chunk_type_text['sample_depth_bits'] = getid3_lib::BigEndian2Int(substr($otherdata, $sPLToffset, 1));
326 $sPLToffset += 1;
327 $thisfile_png_chunk_type_text['sample_depth_bytes'] = $thisfile_png_chunk_type_text['sample_depth_bits'] / 8;
328 $paletteCounter = 0;
329 while ($sPLToffset < strlen($otherdata)) {
330 $thisfile_png_chunk_type_text['red'][$paletteCounter] = getid3_lib::BigEndian2Int(substr($otherdata, $sPLToffset, $thisfile_png_chunk_type_text['sample_depth_bytes']));
331 $sPLToffset += $thisfile_png_chunk_type_text['sample_depth_bytes'];
332 $thisfile_png_chunk_type_text['green'][$paletteCounter] = getid3_lib::BigEndian2Int(substr($otherdata, $sPLToffset, $thisfile_png_chunk_type_text['sample_depth_bytes']));
333 $sPLToffset += $thisfile_png_chunk_type_text['sample_depth_bytes'];
334 $thisfile_png_chunk_type_text['blue'][$paletteCounter] = getid3_lib::BigEndian2Int(substr($otherdata, $sPLToffset, $thisfile_png_chunk_type_text['sample_depth_bytes']));
335 $sPLToffset += $thisfile_png_chunk_type_text['sample_depth_bytes'];
336 $thisfile_png_chunk_type_text['alpha'][$paletteCounter] = getid3_lib::BigEndian2Int(substr($otherdata, $sPLToffset, $thisfile_png_chunk_type_text['sample_depth_bytes']));
337 $sPLToffset += $thisfile_png_chunk_type_text['sample_depth_bytes'];
338 $thisfile_png_chunk_type_text['frequency'][$paletteCounter] = getid3_lib::BigEndian2Int(substr($otherdata, $sPLToffset, 2));
339 $sPLToffset += 2;
340 $paletteCounter++;
341 }
342 break;
343
344
345 case 'hIST': // Palette Histogram
346 $thisfile_png_chunk_type_text['header'] = $chunk;
347 $hISTcounter = 0;
348 while ($hISTcounter < strlen($chunk['data'])) {
349 $thisfile_png_chunk_type_text[$hISTcounter] = getid3_lib::BigEndian2Int(substr($chunk['data'], $hISTcounter / 2, 2));
350 $hISTcounter += 2;
351 }
352 break;
353
354
355 case 'tIME': // Image Last-Modification Time
356 $thisfile_png_chunk_type_text['header'] = $chunk;
357 $thisfile_png_chunk_type_text['year'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 2));
358 $thisfile_png_chunk_type_text['month'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 2, 1));
359 $thisfile_png_chunk_type_text['day'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 3, 1));
360 $thisfile_png_chunk_type_text['hour'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 4, 1));
361 $thisfile_png_chunk_type_text['minute'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 5, 1));
362 $thisfile_png_chunk_type_text['second'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 6, 1));
363 $thisfile_png_chunk_type_text['unix'] = gmmktime($thisfile_png_chunk_type_text['hour'], $thisfile_png_chunk_type_text['minute'], $thisfile_png_chunk_type_text['second'], $thisfile_png_chunk_type_text['month'], $thisfile_png_chunk_type_text['day'], $thisfile_png_chunk_type_text['year']);
364 break;
365
366
367 case 'oFFs': // Image Offset
368 $thisfile_png_chunk_type_text['header'] = $chunk;
369 $thisfile_png_chunk_type_text['position_x'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 4), false, true);
370 $thisfile_png_chunk_type_text['position_y'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 4, 4), false, true);
371 $thisfile_png_chunk_type_text['unit_specifier'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 8, 1));
372 $thisfile_png_chunk_type_text['unit'] = $this->PNGoFFsUnitLookup($thisfile_png_chunk_type_text['unit_specifier']);
373 break;
374
375
376 case 'pCAL': // Calibration Of Pixel Values
377 $thisfile_png_chunk_type_text['header'] = $chunk;
378 list($calibrationname, $otherdata) = explode("\x00", $chunk['data'], 2);
379 $thisfile_png_chunk_type_text['calibration_name'] = $calibrationname;
380 $pCALoffset = 0;
381 $thisfile_png_chunk_type_text['original_zero'] = getid3_lib::BigEndian2Int(substr($chunk['data'], $pCALoffset, 4), false, true);
382 $pCALoffset += 4;
383 $thisfile_png_chunk_type_text['original_max'] = getid3_lib::BigEndian2Int(substr($chunk['data'], $pCALoffset, 4), false, true);
384 $pCALoffset += 4;
385 $thisfile_png_chunk_type_text['equation_type'] = getid3_lib::BigEndian2Int(substr($chunk['data'], $pCALoffset, 1));
386 $pCALoffset += 1;
387 $thisfile_png_chunk_type_text['equation_type_text'] = $this->PNGpCALequationTypeLookup($thisfile_png_chunk_type_text['equation_type']);
388 $thisfile_png_chunk_type_text['parameter_count'] = getid3_lib::BigEndian2Int(substr($chunk['data'], $pCALoffset, 1));
389 $pCALoffset += 1;
390 $thisfile_png_chunk_type_text['parameters'] = explode("\x00", substr($chunk['data'], $pCALoffset));
391 break;
392
393
394 case 'sCAL': // Physical Scale Of Image Subject
395 $thisfile_png_chunk_type_text['header'] = $chunk;
396 $thisfile_png_chunk_type_text['unit_specifier'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 1));
397 $thisfile_png_chunk_type_text['unit'] = $this->PNGsCALUnitLookup($thisfile_png_chunk_type_text['unit_specifier']);
398 list($pixelwidth, $pixelheight) = explode("\x00", substr($chunk['data'], 1));
399 $thisfile_png_chunk_type_text['pixel_width'] = $pixelwidth;
400 $thisfile_png_chunk_type_text['pixel_height'] = $pixelheight;
401 break;
402
403
404 case 'gIFg': // GIF Graphic Control Extension
405 $gIFgCounter = 0;
406 if (isset($thisfile_png_chunk_type_text) && is_array($thisfile_png_chunk_type_text)) {
407 $gIFgCounter = count($thisfile_png_chunk_type_text);
408 }
409 $thisfile_png_chunk_type_text[$gIFgCounter]['header'] = $chunk;
410 $thisfile_png_chunk_type_text[$gIFgCounter]['disposal_method'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 1));
411 $thisfile_png_chunk_type_text[$gIFgCounter]['user_input_flag'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 1, 1));
412 $thisfile_png_chunk_type_text[$gIFgCounter]['delay_time'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 2, 2));
413 break;
414
415
416 case 'gIFx': // GIF Application Extension
417 $gIFxCounter = 0;
418 if (isset($thisfile_png_chunk_type_text) && is_array($thisfile_png_chunk_type_text)) {
419 $gIFxCounter = count($thisfile_png_chunk_type_text);
420 }
421 $thisfile_png_chunk_type_text[$gIFxCounter]['header'] = $chunk;
422 $thisfile_png_chunk_type_text[$gIFxCounter]['application_identifier'] = substr($chunk['data'], 0, 8);
423 $thisfile_png_chunk_type_text[$gIFxCounter]['authentication_code'] = substr($chunk['data'], 8, 3);
424 $thisfile_png_chunk_type_text[$gIFxCounter]['application_data'] = substr($chunk['data'], 11);
425 break;
426
427
428 case 'IDAT': // Image Data
429 $idatinformationfieldindex = 0;
430 if (isset($thisfile_png['IDAT']) && is_array($thisfile_png['IDAT'])) {
431 $idatinformationfieldindex = count($thisfile_png['IDAT']);
432 }
433 unset($chunk['data']);
434 $thisfile_png_chunk_type_text[$idatinformationfieldindex]['header'] = $chunk;
435 break;
436
437
438 case 'IEND': // Image Trailer
439 $thisfile_png_chunk_type_text['header'] = $chunk;
440 break;
441
442
443 default:
444 //unset($chunk['data']);
445 $thisfile_png_chunk_type_text['header'] = $chunk;
446 $this->warning('Unhandled chunk type: '.$chunk['type_text']);
447 break;
448 }
449 }
450
451 return true;
452 }
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1711
fread($bytes)
Definition: getid3.php:1683
warning($text)
Definition: getid3.php:1758
error($text)
Definition: getid3.php:1752
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Definition: getid3.lib.php:18
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: getid3.lib.php:263
PNGsRGBintentLookup($sRGB)
IHDRcalculateBitsPerSample($color_type, $bit_depth)
PNGpHYsUnitLookup($unitid)
PNGpCALequationTypeLookup($equationtype)
PNGcompressionMethodLookup($compressionmethod)
PNGoFFsUnitLookup($unitid)
PNGsCALUnitLookup($unitid)
$i
Definition: disco.tpl.php:19
$red
Definition: example_030.php:80
$green
Definition: example_030.php:83
$blue
Definition: example_030.php:81
$info
Definition: index.php:5
$text
Definition: errorreport.php:18

References $blue, $green, $i, $info, $red, $text, getid3_lib\BigEndian2Int(), getid3_handler\error(), getid3_handler\fread(), getid3_handler\fseek(), getid3_handler\ftell(), IHDRcalculateBitsPerSample(), PNGcompressionMethodLookup(), PNGoFFsUnitLookup(), PNGpCALequationTypeLookup(), PNGpHYsUnitLookup(), PNGsCALUnitLookup(), PNGsRGBintentLookup(), getid3_lib\PrintHexBytes(), and getid3_handler\warning().

+ Here is the call graph for this function:

◆ IHDRcalculateBitsPerSample()

getid3_png::IHDRcalculateBitsPerSample (   $color_type,
  $bit_depth 
)

Definition at line 505 of file module.graphic.png.php.

505 {
506 switch ($color_type) {
507 case 0: // Each pixel is a grayscale sample.
508 return $bit_depth;
509 break;
510
511 case 2: // Each pixel is an R,G,B triple
512 return 3 * $bit_depth;
513 break;
514
515 case 3: // Each pixel is a palette index; a PLTE chunk must appear.
516 return $bit_depth;
517 break;
518
519 case 4: // Each pixel is a grayscale sample, followed by an alpha sample.
520 return 2 * $bit_depth;
521 break;
522
523 case 6: // Each pixel is an R,G,B triple, followed by an alpha sample.
524 return 4 * $bit_depth;
525 break;
526 }
527 return false;
528 }

Referenced by Analyze().

+ Here is the caller graph for this function:

◆ PNGcompressionMethodLookup()

getid3_png::PNGcompressionMethodLookup (   $compressionmethod)

Definition at line 464 of file module.graphic.png.php.

464 {
465 static $PNGcompressionMethodLookup = array(
466 0 => 'deflate/inflate'
467 );
468 return (isset($PNGcompressionMethodLookup[$compressionmethod]) ? $PNGcompressionMethodLookup[$compressionmethod] : 'invalid');
469 }

Referenced by Analyze().

+ Here is the caller graph for this function:

◆ PNGoFFsUnitLookup()

getid3_png::PNGoFFsUnitLookup (   $unitid)

Definition at line 479 of file module.graphic.png.php.

479 {
480 static $PNGoFFsUnitLookup = array(
481 0 => 'pixel',
482 1 => 'micrometer'
483 );
484 return (isset($PNGoFFsUnitLookup[$unitid]) ? $PNGoFFsUnitLookup[$unitid] : 'invalid');
485 }

Referenced by Analyze().

+ Here is the caller graph for this function:

◆ PNGpCALequationTypeLookup()

getid3_png::PNGpCALequationTypeLookup (   $equationtype)

Definition at line 487 of file module.graphic.png.php.

487 {
488 static $PNGpCALequationTypeLookup = array(
489 0 => 'Linear mapping',
490 1 => 'Base-e exponential mapping',
491 2 => 'Arbitrary-base exponential mapping',
492 3 => 'Hyperbolic mapping'
493 );
494 return (isset($PNGpCALequationTypeLookup[$equationtype]) ? $PNGpCALequationTypeLookup[$equationtype] : 'invalid');
495 }

Referenced by Analyze().

+ Here is the caller graph for this function:

◆ PNGpHYsUnitLookup()

getid3_png::PNGpHYsUnitLookup (   $unitid)

Definition at line 471 of file module.graphic.png.php.

471 {
472 static $PNGpHYsUnitLookup = array(
473 0 => 'unknown',
474 1 => 'meter'
475 );
476 return (isset($PNGpHYsUnitLookup[$unitid]) ? $PNGpHYsUnitLookup[$unitid] : 'invalid');
477 }

Referenced by Analyze().

+ Here is the caller graph for this function:

◆ PNGsCALUnitLookup()

getid3_png::PNGsCALUnitLookup (   $unitid)

Definition at line 497 of file module.graphic.png.php.

497 {
498 static $PNGsCALUnitLookup = array(
499 0 => 'meter',
500 1 => 'radian'
501 );
502 return (isset($PNGsCALUnitLookup[$unitid]) ? $PNGsCALUnitLookup[$unitid] : 'invalid');
503 }

Referenced by Analyze().

+ Here is the caller graph for this function:

◆ PNGsRGBintentLookup()

getid3_png::PNGsRGBintentLookup (   $sRGB)

Definition at line 454 of file module.graphic.png.php.

454 {
455 static $PNGsRGBintentLookup = array(
456 0 => 'Perceptual',
457 1 => 'Relative colorimetric',
458 2 => 'Saturation',
459 3 => 'Absolute colorimetric'
460 );
461 return (isset($PNGsRGBintentLookup[$sRGB]) ? $PNGsRGBintentLookup[$sRGB] : 'invalid');
462 }

Referenced by Analyze().

+ Here is the caller graph for this function:

Field Documentation

◆ $max_data_bytes

getid3_png::$max_data_bytes = 10000000

Definition at line 20 of file module.graphic.png.php.


The documentation for this class was generated from the following file: