Search code examples
tizen-web-app

how to use Exif API in Tizen Web Application


to handle image that display vertical, i'm using [exifInfo.orientation = "ROTATE_XXX";]. exifInfo is belong to Exif API. how to use Exif API in Tizen Web Application? While I click on "For more information about how to use Exif API, see Exif Guide." on developer.tizen.org/ko/development/api-references/web-application, that page show nothing.


Solution

  • Tizen enables you to access and modify EXIF information in a JPEG file. The Exif API is mandatory for both Tizen mobile and wearable profiles, which means that it is supported in all mobile and wearable devices. All mandatory APIs are supported on the Tizen Emulators.

    Use:

        var fileURI = "";
        var myNewExif = new tizen.ExifInformation();
    
    
        function getSuccess(exifInfo)
        {
            console.log(exifInfo.orientation);
            console.log(exifInfo.userComment);
            console.log(exifInfo.gpsLocation);
        }
    
        function resolveSuccess(file)
        {
           fileURI = file.toURI();
           console.log("Successfully resolved file: " + file.toURI());
    
           function onSaveSuccess()
           {
              console.log("Successfully saved EXIF information to JPEG file");
           }
    
           function onSaveError(error)
           {
              console.log("Error occurred:" + error.name + " with message:" + error.message);
           }
    
           myNewExif.uri = file.toURI();
           myNewExif.orientation = "ROTATE_90";
           myNewExif.userComment = "Photo taken on Golden Bridge in Sanfrancisco";
           myNewExif.gpsLocation = new tizen.SimpleCoordinates(50.086447, 14.411856);
           tizen.exif.saveExifInfo(myNewExif, onSaveSuccess, onSaveError);
           tizen.exif.getExifInfo(fileURI, getSuccess);
        }
    
        function resolveFail(error)
        {
           console.log("resolve() error occurred: " + error.name + " with message: " + error.message);
        }
    
        tizen.filesystem.resolve("images/image1.jpg", resolveSuccess, resolveFail);
    

    Add these privileges in config.xml

    <tizen:privilege name="http://tizen.org/privilege/content.read"/>
    <tizen:privilege name="http://tizen.org/privilege/content.write"/>
    <tizen:privilege name="http://tizen.org/privilege/filesystem.read"/>
    <tizen:privilege name="http://tizen.org/privilege/filesystem.write"/>