This shows you the differences between two versions of the page.
— |
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( " | ||
+ | you can remove the code specific to " | ||
+ | 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:// | ||
+ | ide.AddModule( " | ||
+ | |||
+ | //Called when application is started. | ||
+ | function OnStart() | ||
+ | { | ||
+ | //Set MUI primary color. | ||
+ | app.InitializeUIKit( MUI.colors.teal.teal, | ||
+ | //Create a MUI card layout. | ||
+ | lay = MUI.CreateLayout(" | ||
+ | |||
+ | path = app.RealPath(app.GetAppPath())+'/ | ||
+ | // | ||
+ | uri = app.Path2Uri(path) | ||
+ | |||
+ | var ExifImage = require(' | ||
+ | try { | ||
+ | new ExifImage({ image : path }, function (error, exifData) { | ||
+ | if (error) | ||
+ | alert(' | ||
+ | else | ||
+ | alert(JSON.stringify(exifData)); | ||
+ | }) | ||
+ | } catch (error) { | ||
+ | alert(' | ||
+ | } | ||
+ | |||
+ | //Add main layout to app. | ||
+ | app.AddLayout(lay) | ||
+ | |||
+ | } | ||
+ | </ |