User Tools

Site Tools


plugins:notesonexif

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

plugins:notesonexif [2022/01/24 17:24] (current)
al4he6 created
Line 1: Line 1:
 +**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.\\
  
 +<code>
 +//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)
 +
 +}
 +</code>
plugins/notesonexif.txt ยท Last modified: 2022/01/24 17:24 by al4he6