Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To obtain the EXIF tag from an image using node.js, you can use the exif package which provides a simple interface to read EXIF data from images.

Here is an example code:

const exif = require('exif');

exif('path/to/image.jpg', (err, data) => {
  if (err) {
    console.log(err);
  } else {
    console.log(data);
  }
});

In this code, we first require the exif package. Then, we call the exif function with the path to the image file as the first argument, and a callback function as the second argument. The callback function receives two arguments - err and data. If there was an error reading the EXIF data, err will be set to the error object. Otherwise, data will contain an object with the EXIF data.

You can then access individual EXIF tags by their name in the data object. For example:

console.log(data.Make); // prints the make of the camera
console.log(data.DateTimeOriginal); // prints the date and time the photo was taken

Note that some EXIF tags may not be present in all images, so you should check whether the tag exists in the data object before attempting to access it.