Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!