FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

image-source saveToFile does not work - related to issue 4237 · Issue #4242 · NativeScript/NativeScript · GitHub

image-source saveToFile does not work - related to issue 4237 #4242

Description

Please help me save a image taken from camera to file.
I need the filename and filepath, so I can take next action to it.
Saving to gallery will not help me, as I do not have the file name. Below is the code. and the error is
JS: TypeError: img.saveToFile is not a function
I am running tns 3.0.1
Help please.

var cameraModule = require("nativescript-camera");
var fs = require('file-system');
var imageSource = require("image-source");
var enumsModule = require('ui/enums');
var imageModule = require("ui/image");
var format = enumsModule.ImageFormat.jpeg
console.log(JSON.stringify(imageSource));
exports.takepic=function(){
console.log('take pic');
cameraModule.requestPermissions()
cameraModule.takePicture({
width: 300,
height: 300,
keepAspectRatio: true
}).then(function (imageAsset) {
console.log("Image taken!");
console.log(JSON.stringify(img));

 try{
var img=imageSource.fromAsset(imageAsset);     
     console.log(JSON.stringify(img));
var folder = fs.knownFolders.documents().path;
console.log('folder - ', folder); // => object
var fileName = 'img_' + new Date().getTime() + '.' + format
var path = fs.path.join(folder, fileName);
console.log('path - ', path); // => correct path


img.saveToFile(path, format); // ### Execution stops here.
console.log('saved - ', saved); 
console.log('saved - ');
}
catch(e){
    console.log(e);
}

var imgLocal = imageSource.fromFile(path);

pageData.camera.set("cameraImage", img);

});
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL