getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //
More...
◆ __construct()
Image_XMP::__construct |
( |
|
$sFilename | ) |
|
Constructor.
- Parameters
-
string | - Name of the image file to access and extract XMP information from. |
Definition at line 402 of file module.tag.xmp.php.
References _get_XMP_text(), and read_XMP_array_from_text().
404 $this->_sFilename = $sFilename;
406 if (is_file($this->_sFilename))
413 $this->_bXMPParse =
true;
read_XMP_array_from_text($xmltext)
Parses a string containing XMP data (XML), and returns an array which contains all the XMP (XML) info...
_get_XMP_text($filename)
Retrieves XMP information from an APP1 JPEG segment and returns the raw XML text as a string...
◆ _get_jpeg_header_data()
Image_XMP::_get_jpeg_header_data |
( |
|
$filename | ) |
|
Reads all the JPEG header segments from an JPEG image file into an array.
- Parameters
-
string | $filename | - the filename of the JPEG file to read |
- Returns
- array $headerdata - Array of JPEG header segments
-
boolean FALSE - if headers could not be read
Definition at line 87 of file module.tag.xmp.php.
References $data, $filename, $GLOBALS, and array.
Referenced by _get_XMP_text().
90 ignore_user_abort(
true);
102 $data = fread($filehnd, 2);
105 if (
$data !=
"\xFF\xD8")
108 echo
'<p>This probably is not a JPEG file</p>'.
"\n";
114 $data = fread($filehnd, 2);
117 if (
$data{0} !=
"\xFF")
125 $hit_compressed_image_data =
false;
131 while ((
$data{1} !=
"\xD9") && (!$hit_compressed_image_data) && (!feof($filehnd)))
135 if ((ord(
$data{1}) < 0xD0) || (ord(
$data{1}) > 0xD7))
139 $sizestr = fread($filehnd, 2);
142 $decodedsize = unpack(
'nsize', $sizestr);
145 $segdatastart = ftell($filehnd);
148 $segdata = fread($filehnd, $decodedsize[
'size'] - 2);
151 $headerdata[] =
array(
152 'SegType' => ord(
$data{1}),
154 'SegDataStart' => $segdatastart,
155 'SegData' => $segdata,
160 if (
$data{1} ==
"\xDA")
163 $hit_compressed_image_data =
true;
168 $data = fread($filehnd, 2);
171 if (
$data{0} !=
"\xFF")
183 ignore_user_abort(
false);
Create styles array
The data for the language used.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
◆ _get_XMP_text()
Image_XMP::_get_XMP_text |
( |
|
$filename | ) |
|
Retrieves XMP information from an APP1 JPEG segment and returns the raw XML text as a string.
- Parameters
-
string | $filename | - the filename of the JPEG file to read |
- Returns
- string $xmp_data - the string of raw XML text
-
boolean FALSE - if an APP 1 XMP segment could not be found, or if an error occured
Definition at line 197 of file module.tag.xmp.php.
References $filename, $i, and _get_jpeg_header_data().
Referenced by __construct().
203 for (
$i = 0;
$i < count($jpeg_header_data);
$i++)
206 if (strcmp($jpeg_header_data[
$i][
'SegName'],
'APP1') == 0)
209 if (strncmp($jpeg_header_data[$i][
'SegData'],
'http://ns.adobe.com/xap/1.0/'.
"\x00", 29) == 0)
213 $xmp_data = substr($jpeg_header_data[$i][
'SegData'], 29);
215 return trim($xmp_data);
_get_jpeg_header_data($filename)
Reads all the JPEG header segments from an JPEG image file into an array.
◆ getAllTags()
Image_XMP::getAllTags |
( |
| ) |
|
Get a copy of all XMP tags extracted from the image.
- Returns
- array - An array of XMP fields as it extracted by the XMPparse() function
Definition at line 75 of file module.tag.xmp.php.
References $_aXMP.
◆ isValid()
Returns the status of XMP parsing during instantiation.
You'll normally want to call this method before trying to get XMP fields.
- Returns
- boolean Returns true if an APP1 segment was found to contain XMP metadata.
Definition at line 65 of file module.tag.xmp.php.
References $_bXMPParse.
◆ read_XMP_array_from_text()
Image_XMP::read_XMP_array_from_text |
( |
|
$xmltext | ) |
|
Parses a string containing XMP data (XML), and returns an array which contains all the XMP (XML) information.
- Parameters
-
string | $xml_text | - a string containing the XMP data (XML) to be parsed |
- Returns
- array $xmp_array - an array containing all xmp details retrieved.
-
boolean FALSE - couldn't parse the XMP data
Definition at line 230 of file module.tag.xmp.php.
References $key, $tags, and array.
Referenced by __construct().
233 if (trim($xmltext) ==
'')
239 $xml_parser = xml_parser_create(
'UTF-8');
246 if (xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, 0) ==
false)
249 xml_parser_free($xml_parser);
256 if (xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0) ==
false)
259 xml_parser_free($xml_parser);
264 if (xml_parse_into_struct($xml_parser, $xmltext, $values,
$tags) == 0)
267 xml_parser_free($xml_parser);
272 xml_parser_free($xml_parser);
275 $xmp_array =
array();
280 $current_property =
'';
281 $container_index = -1;
282 foreach ($values as $xml_elem)
285 switch ($xml_elem[
'tag'])
295 case 'rdf:Description':
296 switch ($xml_elem[
'type'])
300 if (array_key_exists(
'attributes', $xml_elem))
303 foreach (array_keys($xml_elem[
'attributes']) as
$key)
310 $xmp_array[
$key] = $xml_elem[
'attributes'][
$key];
326 if ($xml_elem[
'type'] ==
'complete')
328 if (array_key_exists(
'attributes', $xml_elem))
331 if (isset($xml_elem[
'attributes'][
'xml:lang']) && ($xml_elem[
'attributes'][
'xml:lang'] !=
'x-default'))
336 if ($current_property !=
'')
338 $xmp_array[$current_property][$container_index] = (isset($xml_elem[
'value']) ? $xml_elem[
'value'] :
'');
339 $container_index += 1;
349 switch ($xml_elem[
'type'])
352 $container_index = 0;
355 $container_index = -1;
367 switch ($xml_elem[
'type'])
371 $current_property = $xml_elem[
'tag'];
376 $current_property =
'';
381 $xmp_array[$xml_elem[
'tag']] = (isset($xml_elem[
'attributes']) ? $xml_elem[
'attributes'] : (isset($xml_elem[
'value']) ? $xml_elem[
'value'] :
''));
Create styles array
The data for the language used.
◆ $_aXMP
Image_XMP::$_aXMP = array() |
◆ $_bXMPParse
Image_XMP::$_bXMPParse = false |
◆ $_sFilename
Image_XMP::$_sFilename = null |
The documentation for this class was generated from the following file: