0

I am trying to retrieve EXIF data of an image from which I want to extract GPS related information i.e., Latitude and logitude. So far I have tried atleast 4-5 EXIF packages available in npm/node - exif, exif-parser, node-exif, exifr, exif-js and other 2-3 but didn't get any solid results. Most of them only supported one file type (only JPG or only PNG). I got my best results with eixfr - I was able to extract data of the first image(regardless of extension),but after that when I tried it with the second image it crashed (happened everytime).

So is there any npm package with which I can retrieve EXIF data of multiple images with different extensions (atleast PNG, JPG , JPEG)?

2 Answers2

0

By using node-exif Package in NodeJs We can get all related data:-

Please refer the link for get the full usage [1]: https://www.npmjs.com/package/exif

  • Thank you for answering. But if you refer to my question I have mentioned there that I have tried node-exif and it fails to read exif data for a .tiff image. – krushnakantL Nov 18 '22 at 06:07
  • I just started playing around with a package called ExifReader at https://www.npmjs.com/package/exifreader. I am working with PNG and JPG but the notes say it supports TIFF too. – Robert G. Schaffrath Mar 22 '23 at 14:01
0

convert to js promise to be able to use with async/await

import exif from 'exif'

export async function getExifAsync(imgPath) {
    return new Promise(function(resolve, reject) {
        new exif.ExifImage({ image : imgPath }, function (error, exifData) {
            if (error) {
                reject(error)
            } else {
                resolve(exifData)
            }
        });
    })
}
const exifData = await getExifAsync(imgPath)
console.log(exifData)
dragansr
  • 417
  • 6
  • 8