22 {
23 $info = &$this->getid3->info;
24
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
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)