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);
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);
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'] :
''));
404 $this->_sFilename = $sFilename;
406 if (is_file($this->_sFilename))
413 $this->_bXMPParse =
true;
An exception for terminatinating execution or to throw for unit testing.
getID3() by James Heinrich info@getid3.org //
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($filename)
Reads all the JPEG header segments from an JPEG image file into an array.
getAllTags()
Get a copy of all XMP tags extracted from the image.
isValid()
Returns the status of XMP parsing during instantiation.
__construct($sFilename)
Constructor.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.