ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GetId3\Module\Graphic\Svg Class Reference

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

+ Inheritance diagram for GetId3\Module\Graphic\Svg:
+ Collaboration diagram for GetId3\Module\Graphic\Svg:

Public Member Functions

 analyze ()
 
- Public Member Functions inherited from GetId3\Handler\BaseHandler
 __construct (GetId3Core $getid3, $call_module=null)
 
 analyze ()
 Analyze from file pointer. More...
 
 AnalyzeString (&$string)
 Analyze from string instead. More...
 
 saveAttachment (&$ThisFileInfoIndex, $filename, $offset, $length)
 

Additional Inherited Members

- Protected Member Functions inherited from GetId3\Handler\BaseHandler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
- Protected Attributes inherited from GetId3\Handler\BaseHandler
 $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 //.

module for analyzing SVG Image files

Author
James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g http://www.getid3.org

Definition at line 28 of file Svg.php.

Member Function Documentation

◆ analyze()

GetId3\Module\Graphic\Svg::analyze ( )
Returns
boolean

Reimplemented from GetId3\Handler\BaseHandler.

Definition at line 34 of file Svg.php.

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

References $info, GetId3\Handler\BaseHandler\fread(), and GetId3\Handler\BaseHandler\fseek().

+ Here is the call graph for this function:

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