How to Get Image Metadata (Including EXIF & Resolution) using Node.js

Cloudmersive
2 min readJul 13, 2022

You can do a lot of useful things with metadata from an image file. Some great examples include cataloguing photo information, streamlining SEO, and helping protect intellectual property. Thankfully, there’s an API for that: our Image Metadata API will allow you to strip all information from an image file, including EXIF data (only if present), and details about image resolution.

Below, we’ll demonstrate how you can take advantage of this API for free by structuring your API call with ready-to-run Node.js snippets. You can also utilize this API as a connector in Power Automate/Logic Apps, or instead visit the Cloudmersive API Console to find instructions for different programming languages.

Let’s start off by running the following command to install the Node.js SDK:

npm install cloudmersive-image-api-client --save

With installation complete, let’s add the following code block to structure the API call. To configure your API key, register a free account on our website and add your key to the Apikey variable.

var CloudmersiveImageApiClient = require('cloudmersive-image-api-client');
var defaultClient = CloudmersiveImageApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveImageApiClient.InfoApi();var imageFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.infoGetMetadata(imageFile, callback);

After that, you’re all set — no more contributions required.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.