Answered step by step
Verified Expert Solution
Question
1 Approved Answer
language: javascript proivde helper function that uses the parse-dms node package to convert the GPSLatitude and GPSLongitude into degrees rather than DMS. const imageBucket =
language: javascript
proivde helper function that uses the parse-dms node package to convert the GPSLatitude and GPSLongitude into degrees rather than DMS.
const imageBucket = storage.bucket(photo.bucket);
//Create a working directory
const workingDir = path.join(os.tmpdir(), 'exif');
const tmpFilePath = path.join(workingDir, photo.name);
//Wait until the temp directory is ready
await fs.ensureDir(workingDir);
//Download file to temp directory
await imageBucket.file(photo.name).download ({
destination: tmpFilePath
});
try {
//call our helper function that getx EXIF from the local file.
getExif(tmpFilePath);
} catch(error){
console.log('Error: ' + error.message);
}
// clean Up
await fs. remove(workingDir);
return true;
};
// helper functions
function getExif(tempImage) {
new ExifImage(
{ image : tempImage},
function (error, exifData) {
if (error)
console.log('Error: ' + error.message);
else
//cal helper function that writes EXIF data to the log
logExif(exifData);
}
)
}
function logExif(data) {
console.log(data.gps.GPSLatitude[0]);
console.log(data.gps.GPSLatitude[1]);
console.log(data.gps.GPSLatitude[2]);
console.log(data.gps.GPSLongitude[0]);
console.log(data.gps.GPSLongitude[1]);
console.log(data.gps.GPSLongitude[2]);
};
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started