Currently, I am in the process of developing a web application using Angular 8. My main objective is to access the exif data of an input image outside the getData method by assigning the obtained data to a global variable. However, when attempting to access the global variable after executing the function, it returns undefined. Below is the function used for extracting the exif data:
photodata: any; // global variable
getPhotodata(file) {
EXIF.getData(file, function() {
const data = EXIF.getAllTags(this);
console.log(data); // working
console.log(data.Make); // working
console.log(data.Model); // working
console.log(data.DateTimeOriginal); // working
this.photodata = data;
console.log(this.photodata) // working
});
}
console.log(this.photodata) // returns as undefined here
I have also attempted to return the data, however, that approach did not work either.
getPhotodata(file) {
EXIF.getData(file, function() {
const data = EXIF.getAllTags(this);
console.log(data); // working
console.log(data.Make); // working
console.log(data.Model); // working
console.log(data.DateTimeOriginal); // working
return data;
});
}
console.log(getPhotodata(file)) // returns as undefined