How to detect and highlight the edges of an image in Node.JS

After today, you’ll never have to worry about edge detection again. I’m going to show you how to perform this operation with virtually no hassle in just a few short minutes. Let’s get straight to it.

We start off with using npm install to set up our API client.

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

Now to invoke filterEdgeDetect with this snippet here.

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.FilterApi();var radius = 56; // Number | Radius in pixels of the edge detection operation; a larger radius will produce a greater effectvar 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.filterEdgeDetect(radius, imageFile, callback);

Enter your radius for the effect, measured in pixels, then input your image and you’re home free! The API will do the rest. Easy.

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