dragon66 / icafe

Java library for reading, writing, converting and manipulating images and metadata
Eclipse Public License 1.0
204 stars 58 forks source link

writing predefined xmp to a jpg file #103

Closed ilker-aktuna closed 3 years ago

ilker-aktuna commented 3 years ago

I am working on an Android app which converts stereo (dual fisheye) 360 degree panorama images to equirectangular format. I need to write xmp data to the file to make the final image be played in 360 degree.

I have the xmp structure predefined (below)

is it possible to use icafe library to write this to an image ?


public String generatePhotoSphereXMP(int width, int height, int sourceImageCount) {
        return "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" +
                "<rdf:Description rdf:about=\"\" xmlns:GPano=\"http://ns.google.com/photos/1.0/panorama/\">\n" +
                "    <GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>\n" +
                "    <GPano:CaptureSoftware>CyanogenMod Focal</GPano:CaptureSoftware>\n" +
                "    <GPano:StitchingSoftware>CyanogenMod Focal with Hugin</GPano:StitchingSoftware>\n" +
                "    <GPano:ProjectionType>equirectangular</GPano:ProjectionType>\n" +
                "    <GPano:PoseHeadingDegrees>350.0</GPano:PoseHeadingDegrees>\n" +
                "    <GPano:InitialViewHeadingDegrees>90.0</GPano:InitialViewHeadingDegrees>\n" +
                "    <GPano:InitialViewPitchDegrees>45.0</GPano:InitialViewPitchDegrees>\n" +
                //"    <GPano:InitialViewRollDegrees>"+mOrientation+"</GPano:InitialViewRollDegrees>\n" +
                //"    <GPano:InitialHorizontalFOVDegrees>"+mHorizontalAngle+"</GPano:InitialHorizontalFOVDegrees>\n" +
                "    <GPano:CroppedAreaLeftPixels>0</GPano:CroppedAreaLeftPixels>\n" +
                "    <GPano:CroppedAreaTopPixels>0</GPano:CroppedAreaTopPixels>\n" +
                //"    <GPano:CroppedAreaImageWidthPixels>"+(width)+"</GPano:CroppedAreaImageWidthPixels>\n" +
                //"    <GPano:CroppedAreaImageHeightPixels>"+(height)+"</GPano:CroppedAreaImageHeightPixels>\n" +
                //"    <GPano:FullPanoWidthPixels>"+width+"</GPano:FullPanoWidthPixels>\n" +
                //"    <GPano:FullPanoHeightPixels>"+height+"</GPano:FullPanoHeightPixels>\n" +
                //"    <GPano:FirstPhotoDate>2012-11-07T21:03:13.465Z</GPano:FirstPhotoDate>\n" +
                //"    <GPano:LastPhotoDate>2012-11-07T21:04:10.897Z</GPano:LastPhotoDate>\n" +
                //"    <GPano:SourcePhotosCount>"+sourceImageCount+"</GPano:SourcePhotosCount>\n" +
                "    <GPano:ExposureLockUsed>False</GPano:ExposureLockUsed>\n" +
                "</rdf:Description></rdf:RDF>";
    }
dragon66 commented 3 years ago

@ilker-aktuna it is very easy to insert pre-defined xmp string into a JPEG file.

I thought I included an example in the test folder but seems there is no direct example for xmp insertion.

What you need to do is call Metadata.insertXMP(is, os, generatePhotoSphereXMP) with several parameters like input, output stream as well as a xmp string and icafe will take care of it.

The format of your example seems correct.

Let me know if it works.

Wen

ilker-aktuna commented 3 years ago

thanks. it worked !

now I have to find a similar way to add spherical metadata to 360 degree videos as well. any idea if that is achieveable by icafe ?

dragon66 commented 3 years ago

@ilker-aktuna not sure how videos incorporate the meta data but icafe can only add xmp to individual images.

Wen

ilker-aktuna commented 3 years ago

I found some other library for injecting spherical metadata to video files. it uses a precompiled library but it works. thanks for the help.