PeterStaev / nativescript-photo-editor

🎨 Easily edit an image in your NativeScript app (crop, draw, etc)
Apache License 2.0
47 stars 15 forks source link

Cannot get the captured image in order to pass it to the PhotoEditor #29

Open jpw9 opened 4 years ago

jpw9 commented 4 years ago

hello, i am using nativescript-camera plugin to capture an image and i am saving the resulting ImageAsset and usging ImageSource, i am doing the below to save to file: ImageSource.fromAsset(picture).then( savedImage => { let filename = "image" + "-" + new Date().getTime() + ".png"; let folder = fsModule.knownFolders.documents(); let path = fsModule.path.join(folder.path, filename); savedImage.saveToFile(path, "png"); ..... This is the path: path:/data/user/0/org.nativescript.preview/files/image-1586246616272.png

Now i am trying to access this image in order to pass it to the PhotoEditor instance as per the below: var loadedImage = ImageSource.fromFileSync(path); //same path of the saved Image photoEditor.editPhoto({ imageSource: loadedImage }).then((newImage: ImageAsset) => { .... }).catch((e) => { console.error(e); }); But i am always failing to get the loadedImage. Is there anything i am missing? i am using nativescript angular project and NS version is 6.4.1

PeterStaev commented 4 years ago

@jpw9 , dont think this issue is related to the photo-editor plugin. It could be a problem with the file not fully saved when you try to load it, path being overwritten or something else. I suggest you debug your code and check if the path is the same and make sure the image is fully saved before the edit method is called.

jpw9 commented 4 years ago

thank you for your reply. i will try to check with the path to make sure nothing is being overwritten and i am getting the right path.