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 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.
◆ analyze()
GetId3\Module\Graphic\Svg::analyze |
( |
| ) |
|
- Returns
- boolean
Definition at line 34 of file Svg.php.
References $info, array, GetId3\Handler\BaseHandler\fread(), and GetId3\Handler\BaseHandler\fseek().
36 $info = &$this->getid3->info;
38 fseek($this->getid3->fp,
$info[
'avdataoffset'], SEEK_SET);
40 $SVGheader =
fread($this->getid3->fp, 4096);
41 if (preg_match(
'#<\?xml([^>]+)\?>#i', $SVGheader, $matches)) {
42 $info[
'svg'][
'xml'][
'raw'] = $matches;
44 if (preg_match(
'#<\!DOCTYPE([^>]+)>#i', $SVGheader, $matches)) {
45 $info[
'svg'][
'doctype'][
'raw'] = $matches;
47 if (preg_match(
'#<svg([^>]+)>#i', $SVGheader, $matches)) {
48 $info[
'svg'][
'svg'][
'raw'] = $matches;
50 if (isset(
$info[
'svg'][
'svg'][
'raw'])) {
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])) {
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]);
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]);
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);
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,
'"');
78 $info[
'fileformat'] =
'svg';
79 $info[
'video'][
'dataformat'] =
'svg';
80 $info[
'video'][
'lossless'] =
true;
82 $info[
'video'][
'pixel_aspect_ratio'] = (float) 1;
84 if (!empty(
$info[
'svg'][
'svg'][
'sections'][
'width'])) {
85 $info[
'svg'][
'width'] = intval(
$info[
'svg'][
'svg'][
'sections'][
'width']);
87 if (!empty(
$info[
'svg'][
'svg'][
'sections'][
'height'])) {
88 $info[
'svg'][
'height'] = intval(
$info[
'svg'][
'svg'][
'sections'][
'height']);
90 if (!empty(
$info[
'svg'][
'svg'][
'sections'][
'version'])) {
91 $info[
'svg'][
'version'] =
$info[
'svg'][
'svg'][
'sections'][
'version'];
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];
102 if (!empty(
$info[
'svg'][
'width'])) {
103 $info[
'video'][
'resolution_x'] =
$info[
'svg'][
'width'];
105 if (!empty(
$info[
'svg'][
'height'])) {
106 $info[
'video'][
'resolution_y'] =
$info[
'svg'][
'height'];
111 $info[
'error'][] =
'Did not find expected <svg> tag';
fseek($bytes, $whence=SEEK_SET)
Create styles array
The data for the language used.
The documentation for this class was generated from the following file:
- libs/composer/vendor/phansys/getid3/GetId3/Module/Graphic/Svg.php