Last active
January 23, 2016 17:22
-
-
Save miya0001/12f8537f54fea59a1de9 to your computer and use it in GitHub Desktop.
PHPで Photo Sphere XMP Metadataをパース
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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