Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@miya0001
Last active January 23, 2016 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miya0001/12f8537f54fea59a1de9 to your computer and use it in GitHub Desktop.
Save miya0001/12f8537f54fea59a1de9 to your computer and use it in GitHub Desktop.
PHPで Photo Sphere XMP Metadataをパース
<?php
$ns = 'http://ns.google.com/photos/1.0/panorama/'
$image = '/path/to/image.jpg';
$content = file_get_contents( $image );
$xmp_data_start = strpos( $content, '<x:xmpmeta' );
$xmp_data_end = strpos( $content, '</x:xmpmeta>' );
$xmp_length = $xmp_data_end - $xmp_data_start;
if ( $xmp_length ) {
$xmp_data = substr( $content, $xmp_data_start, $xmp_length + 12 );
$xmp = simplexml_load_string( $xmp_data );
$xmp = $xmp->children( "http://www.w3.org/1999/02/22-rdf-syntax-ns#" );
$xmp = $xmp->RDF->Description;
if ( "TRUE" === strtoupper( (string) $xmp->attributes( $ns )->UsePanoramaViewer ) ) {
return true;
} elseif ( "TRUE" === strtoupper( (string) $xmp->children( $ns )->UsePanoramaViewer ) ) {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment