I need to add Gpano metadata progammatically in PHP but I don't know how to do.
The input : A simple 360 image without Gpano metadatas. Format : jpeg, jpg.
The output : The image has to works with Facebook 360 with Gpano metadatas like that :
<rdf:Description rdf:about="" xmlns:GPano="http://ns.google.com/photos/1.0/panorama/">
<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>
<GPano:CaptureSoftware>Photo Sphere</GPano:CaptureSoftware>
<GPano:StitchingSoftware>Photo Sphere</GPano:StitchingSoftware>
<GPano:ProjectionType>equirectangular</GPano:ProjectionType>
<GPano:PoseHeadingDegrees>350.0</GPano:PoseHeadingDegrees>
<GPano:InitialViewHeadingDegrees>90.0</GPano:InitialViewHeadingDegrees>
<GPano:InitialViewPitchDegrees>0.0</GPano:InitialViewPitchDegrees>
<GPano:InitialViewRollDegrees>0.0</GPano:InitialViewRollDegrees>
<GPano:InitialHorizontalFOVDegrees>75.0</GPano:InitialHorizontalFOVDegrees>
<GPano:CroppedAreaLeftPixels>0</GPano:CroppedAreaLeftPixels>
<GPano:CroppedAreaTopPixels>0</GPano:CroppedAreaTopPixels>
<GPano:CroppedAreaImageWidthPixels>4000</GPano:CroppedAreaImageWidthPixels>
<GPano:CroppedAreaImageHeightPixels>2000</GPano:CroppedAreaImageHeightPixels>
<GPano:FullPanoWidthPixels>4000</GPano:FullPanoWidthPixels>
<GPano:FullPanoHeightPixels>2000</GPano:FullPanoHeightPixels>
<GPano:FirstPhotoDate>2012-11-07T21:03:13.465Z</GPano:FirstPhotoDate>
<GPano:LastPhotoDate>2012-11-07T21:04:10.897Z</GPano:LastPhotoDate>
<GPano:SourcePhotosCount>50</GPano:SourcePhotosCount>
<GPano:ExposureLockUsed>False</GPano:ExposureLockUsed>
</rdf:Description>
The most important are these lines :
<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>
<GPano:ProjectionType>equirectangular</GPano:ProjectionType>
I tried The PHP JPEG Metadata Toolkit available here : http://www.ozhiker.com/electronics/pjmt/ And here is my code but idk what to add exactly :
require_once('PHP_JPEG_Metadata_Toolkit_1.12/JPEG.php');
require_once('PHP_JPEG_Metadata_Toolkit_1.12/XMP.php');
$metas = get_jpeg_header_data('image.jpg');
put_XMP_text($metas, 'what to write here ?');
I also tried windows software that's works perfectly, but impossible to use it on my webserver (linux) : Exif Fixer for Windows Available here : http://panoramaphotographer.com/software/exiffixer/
If someone can help me with my code, or if someone can post an example that's works, it will be awesome !
Thank you in advance all.
I used the The PHP JPEG Metadata Toolkit.
Just beware it hasn't been updated in few years and will likely throw some errors in PHP 7+ that can be easily fixed (like short opening php tags and 0s before numbers).
After this is fixed, the usage is pretty straightforward:
require 'PHP_JPEG_Metadata_Toolkit_1.12/' . 'EXIF.php';
$filename = 'test.jpg';
$jpeg_header_data = get_jpeg_header_data($filename);
$xmp = '
<rdf:Description rdf:about="" xmlns:GPano="http://ns.google.com/photos/1.0/panorama/">
<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>
<GPano:CaptureSoftware>Photo Sphere</GPano:CaptureSoftware>
<GPano:StitchingSoftware>Photo Sphere</GPano:StitchingSoftware>
<GPano:ProjectionType>equirectangular</GPano:ProjectionType>
<GPano:PoseHeadingDegrees>350.0</GPano:PoseHeadingDegrees>
<GPano:InitialViewHeadingDegrees>90.0</GPano:InitialViewHeadingDegrees>
<GPano:InitialViewPitchDegrees>0.0</GPano:InitialViewPitchDegrees>
<GPano:InitialViewRollDegrees>0.0</GPano:InitialViewRollDegrees>
<GPano:InitialHorizontalFOVDegrees>75.0</GPano:InitialHorizontalFOVDegrees>
<GPano:CroppedAreaLeftPixels>0</GPano:CroppedAreaLeftPixels>
<GPano:CroppedAreaTopPixels>0</GPano:CroppedAreaTopPixels>
<GPano:CroppedAreaImageWidthPixels>4000</GPano:CroppedAreaImageWidthPixels>
<GPano:CroppedAreaImageHeightPixels>2000</GPano:CroppedAreaImageHeightPixels>
<GPano:FullPanoWidthPixels>4000</GPano:FullPanoWidthPixels>
<GPano:FullPanoHeightPixels>2000</GPano:FullPanoHeightPixels>
<GPano:FirstPhotoDate>2012-11-07T21:03:13.465Z</GPano:FirstPhotoDate>
<GPano:LastPhotoDate>2012-11-07T21:04:10.897Z</GPano:LastPhotoDate>
<GPano:SourcePhotosCount>50</GPano:SourcePhotosCount>
<GPano:ExposureLockUsed>False</GPano:ExposureLockUsed>
</rdf:Description>
';
$jpeg_header_data = put_XMP_text($jpeg_header_data, $xmp);
put_jpeg_header_data($filename, $filename, $jpeg_header_data);
You can find more info about the required XMP metadata in Google Developers documentation page.