ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
getid3_svg Class Reference

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

+ Inheritance diagram for getid3_svg:
+ Collaboration diagram for getid3_svg:

Public Member Functions

 getid3_svg (&$fd, &$ThisFileInfo)
 
 Analyze ()
 
- 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)
 

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.svg.php.

Member Function Documentation

◆ Analyze()

getid3_svg::Analyze ( )

Reimplemented from getid3_handler.

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

22 {
23 $info = &$this->getid3->info;
24
25 $this->fseek($info['avdataoffset']);
26
27 $SVGheader = $this->fread(4096);
28 if (preg_match('#<\?xml([^>]+)\?>#i', $SVGheader, $matches)) {
29 $info['svg']['xml']['raw'] = $matches;
30 }
31 if (preg_match('#<\!DOCTYPE([^>]+)>#i', $SVGheader, $matches)) {
32 $info['svg']['doctype']['raw'] = $matches;
33 }
34 if (preg_match('#<svg([^>]+)>#i', $SVGheader, $matches)) {
35 $info['svg']['svg']['raw'] = $matches;
36 }
37 if (isset($info['svg']['svg']['raw'])) {
38
39 $sections_to_fix = array('xml', 'doctype', 'svg');
40 foreach ($sections_to_fix as $section_to_fix) {
41 if (!isset($info['svg'][$section_to_fix])) {
42 continue;
43 }
44 $section_data = array();
45 while (preg_match('/ "([^"]+)"/', $info['svg'][$section_to_fix]['raw'][1], $matches)) {
46 $section_data[] = $matches[1];
47 $info['svg'][$section_to_fix]['raw'][1] = str_replace($matches[0], '', $info['svg'][$section_to_fix]['raw'][1]);
48 }
49 while (preg_match('/([^\s]+)="([^"]+)"/', $info['svg'][$section_to_fix]['raw'][1], $matches)) {
50 $section_data[] = $matches[0];
51 $info['svg'][$section_to_fix]['raw'][1] = str_replace($matches[0], '', $info['svg'][$section_to_fix]['raw'][1]);
52 }
53 $section_data = array_merge($section_data, preg_split('/[\s,]+/', $info['svg'][$section_to_fix]['raw'][1]));
54 foreach ($section_data as $keyvaluepair) {
55 $keyvaluepair = trim($keyvaluepair);
56 if ($keyvaluepair) {
57 $keyvalueexploded = explode('=', $keyvaluepair);
58 $key = (isset($keyvalueexploded[0]) ? $keyvalueexploded[0] : '');
59 $value = (isset($keyvalueexploded[1]) ? $keyvalueexploded[1] : '');
60 $info['svg'][$section_to_fix]['sections'][$key] = trim($value, '"');
61 }
62 }
63 }
64
65 $info['fileformat'] = 'svg';
66 $info['video']['dataformat'] = 'svg';
67 $info['video']['lossless'] = true;
68 //$info['video']['bits_per_sample'] = 24;
69 $info['video']['pixel_aspect_ratio'] = (float) 1;
70
71 if (!empty($info['svg']['svg']['sections']['width'])) {
72 $info['svg']['width'] = intval($info['svg']['svg']['sections']['width']);
73 }
74 if (!empty($info['svg']['svg']['sections']['height'])) {
75 $info['svg']['height'] = intval($info['svg']['svg']['sections']['height']);
76 }
77 if (!empty($info['svg']['svg']['sections']['version'])) {
78 $info['svg']['version'] = $info['svg']['svg']['sections']['version'];
79 }
80 if (!isset($info['svg']['version']) && isset($info['svg']['doctype']['sections'])) {
81 foreach ($info['svg']['doctype']['sections'] as $key => $value) {
82 if (preg_match('#//W3C//DTD SVG ([0-9\.]+)//#i', $key, $matches)) {
83 $info['svg']['version'] = $matches[1];
84 break;
85 }
86 }
87 }
88
89 if (!empty($info['svg']['width'])) {
90 $info['video']['resolution_x'] = $info['svg']['width'];
91 }
92 if (!empty($info['svg']['height'])) {
93 $info['video']['resolution_y'] = $info['svg']['height'];
94 }
95
96 return true;
97 }
98 $info['error'][] = 'Did not find expected <svg> tag';
99 return false;
100 }
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
fread($bytes)
Definition: getid3.php:1685
$info
Definition: example_052.php:80

References $info, getid3_handler\fread(), and getid3_handler\fseek().

+ Here is the call graph for this function:

◆ getid3_svg()

getid3_svg::getid3_svg ( $fd,
$ThisFileInfo 
)

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

22 {
23 fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
24
25 // I'm making this up, please modify as appropriate
26 $SVGheader = fread($fd, 32);
27 $ThisFileInfo['svg']['magic'] = substr($SVGheader, 0, 4);
28 if ($ThisFileInfo['svg']['magic'] == 'aBcD') {
29
30 $ThisFileInfo['fileformat'] = 'svg';
31 $ThisFileInfo['video']['dataformat'] = 'svg';
32 $ThisFileInfo['video']['lossless'] = true;
33 $ThisFileInfo['video']['bits_per_sample'] = 24;
34 $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
35
36 $ThisFileInfo['svg']['width'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
37 $ThisFileInfo['svg']['height'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 4));
38
39 $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['svg']['width'];
40 $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['svg']['height'];
41
42 return true;
43 }
44 $ThisFileInfo['error'][] = 'Did not find SVG magic bytes "aBcD" at '.$ThisFileInfo['avdataoffset'];
45 unset($ThisFileInfo['fileformat']);
46 return false;
47 }
LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:266

References getid3_handler\fread(), getid3_handler\fseek(), and getid3_lib\LittleEndian2Int().

+ Here is the call graph for this function:

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