You are here

function exif_custom_get_xmp in EXIF Custom 7

1 call to exif_custom_get_xmp()
exif_custom_get_exif_fields in ./exif_custom.module

File

./exif_custom.module, line 429
Primary hook implementations for EXIF Custom.

Code

function exif_custom_get_xmp($image) {
  $content = file_get_contents($image);
  $xmp_data_start = strpos($content, '<x:xmpmeta');
  $xmp_data_end = strpos($content, '</x:xmpmeta>');
  if ($xmp_data_start === FALSE || $xmp_data_end === FALSE) {
    return array();
  }
  $xmp_length = $xmp_data_end - $xmp_data_start;
  $xmp_data = substr($content, $xmp_data_start, $xmp_length + 12);
  unset($content);
  $xmp = simplexml_load_string($xmp_data);
  if ($xmp === FALSE) {
    return array();
  }

  // $namespaces = $xmp->getDocNamespaces(true);
  // $fields = array();
  // foreach ($namespaces as $namespace) {
  // $fields[] = exif_custom_xml_recursion($xmp->children($namespace));
  $field_data = array();
  exif_custom_xml_recursion($xmp, $field_data, 'XMP');
  return $field_data;
}