Open Source JavaScript Library for Image Processing

Open Source API for Cropping Images Smartly

What is SmartCrop.js?

SmartCrop.js is free and open-source API that allows JavaScript developer to crop images automatically. The API is content aware and uses set of algorithms to crop images. The API finds edges using the laplace, finds faces by finding regions with color like skin, finds regions with high saturation and processes the image. After finding a specific region, the API boost that region and generates a set of candidate crops.

While cropping the image, you can use HTMLImageElement, HTMLCanvasElement or HTMLVideoElement and set image cropping options including minScale, width, height, boost, and ruleOfThirds.

Previous Next

Getting Started with SmartCrop.js

The recommended way to install SmartCrop.js via NPM. Please use the following command to install it.

Install SmartCrop.js via NPM

 npm install smartcrop 

Smart Crop Images via Free JavaScript API

The open source SmartCrop.js library allows JavaScript developers to smart crop images programmatically. Based on the API algorithm, the API finds high saturation areas, finds color with skin tones, and find edges and provides a smart guess to crop the image. In order to smart crop the image, the API provides smartcrop.crop(image, options) method. The method gets and image and image options for the crop. By using the following one line of code, you can easily get an smart crop for your image

Smart Crop Image in JavaScript

  1. Import Library
  2. Crop Image

Crop Image in JavaScript

smartcrop.crop(image, { width: 100, height: 100 }).then(function(result) {
console.log(result);
});