User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


Frequently Asked Questions


Namespaces

Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax

plugins:notesonexif

How to use Nodejs package ExIf in DS (step by step with sample code)
(ExIf can be used to read the data from a photo; which includes size, location, technical details, etc)
(not sure if ide.AddModule is a Premium function)

First find the package on www.npmjs.com
(npmjs usually has a section labelled Usage which shows the javascript you'll need later)
In DS touch 3-vertical-dots icon & touch New;
Create a new project/app npmexif, Native, Node Native, OK
Edit your new project/app (npmexif), edit to ide.AddModule( “exif” )
you can remove the code specific to “moment”
Run the code, it'll ask if you want to install module (touch Yes), then it'll tell you it's installing
(your files app will now show a subdirectory in your project/app called node_modules)
Edit the code as below (for other packages see the Usage section npmjs)
you'll need to add a jpg photo (touch 3rd icon at bottom, touch +, find the photo) rename the photo to myImage..jpg or edit the name in the code, run it.

//Configure app to use NodeJS as the main scripting engine
//giving you the full power of Node directly in your app!
cfg.Node

//Configure for Material UI and light theme.
cfg.MUI, cfg.Light

//Make sure the required node modules are installed to ide.
//(This downloads modules from https://www.npmjs.com).
ide.AddModule( "exif" )

//Called when application is started.
function OnStart()
{
    //Set MUI primary color.
    app.InitializeUIKit( MUI.colors.teal.teal, "Light" )
    //Create a MUI card layout.
    lay = MUI.CreateLayout("Linear", "VCenter,FillXY")

path = app.RealPath(app.GetAppPath())+'/Img/myImage.jpg'
//alert(path)
uri = app.Path2Uri(path)

var ExifImage = require('exif').ExifImage
 try {
    new ExifImage({ image : path }, function (error, exifData) {
        if (error)
            alert('Error: '+error.message);
        else
            alert(JSON.stringify(exifData));
    })
} catch (error) {
    alert('Error: ' + error.message);
}

    //Add main layout to app.
    app.AddLayout(lay)

}
plugins/notesonexif.txt · Last modified: 2022/01/24 17:24 by al4he6