Environment
LINUX OS (DEB)
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):
✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.3.3 version and is up to date.
✔ Component tns-core-modules has 6.3.2 version and is up to date.
✔ Component tns-android has 6.3.1 version and is up to date. # testing on emulator
*Function deprecated error *
While using saving image got error warning,
JS: 'fromFile() is deprecated. Use ImageSource.fromFileSync() instead.'
when i fixed as per then give fatal error
JS: 'Error -> imageSourceModule.fromFileSync is not a function'
How to fix this ?
@akwatra can you give a code snippet or demo project that demonstrates your case?
I guess you can test with "tns-core-modules/image-source"
its reference from there
saveImage(imageAsset){
const img = imageSourceModule.fromFile(imageAsset._android);
const folderDest = fileSystemModule.knownFolders.documents();
const pathDest = fileSystemModule.path.join(folderDest.path, "app/images/" + "_test.png");
const saved = img.saveToFile(pathDest, "png");
if (saved) {
console.log("Image saved successfully!");
that.imgBill = pathDest;
}
}
@akwatra the thing is that the new fromFileSync is a static method of ImageSource class. So that said you need to call it via the ImageSource class itself.
Here is a TypeScript example to make things more clear
import { fromFile, ImageSource } from "tns-core-modules/image-source";
const imgWithDeprecatedMethod = fromFile(path);
const img = ImageSource.fromFileSync(path);
And the same in plain JavaScript
let fromFile = require("tns-core-modules/image-source").fromFile; // deprecated method
let ImageSource = require("tns-core-modules/image-source").ImageSource;
let imgWithDeprecatedMethod = fromFile(path);
let img = ImageSource.fromFileSync(path);
Most helpful comment
@akwatra the thing is that the new fromFileSync is a static method of ImageSource class. So that said you need to call it via the ImageSource class itself.
Here is a TypeScript example to make things more clear
And the same in plain JavaScript