How to remove EXIF data from an image file in Node.JS

EXIF data contains a host of information, which is great for the photographer, but not so great when it comes to personal privacy. Location and time stamp data in particular can potentially cause a lot of security problems. It is generally best to strip all of this information away before opening up files to the public. Today we are going to show you how to use an API to do this really easily, effectively removing this security thorn from your side with little to no headache.

We begin with a reference added to our package.json file, one that will install our API client so we can access its functions.

"dependencies": {
"cloudmersive-image-api-client": "^1.2.3"
}

Proceed to our function call:

var CloudmersiveImageApiClient = require('cloudmersive-image-api-client');var defaultClient = CloudmersiveImageApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveImageApiClient.EditApi();var imageFile = "/path/to/file"; // 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.editRemoveExifData(imageFile, callback);

With our function set up, any imageFile that we input will be sent to the API for EXIF data and profile stripping. It’s as simple as that.

Image for post
Image for post

Written by

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store