smart-crop

Get smart cropping coordinates to an images (based on https://github.com/thumbor/thumbor/wiki/Detection-algorithms)

Usage no npm install needed!

<script type="module">
  import smartCrop from 'https://cdn.skypack.dev/smart-crop';
</script>

README

smart-crop Build Status

Get smart cropping coordinates to an images (based on https://github.com/thumbor/thumbor/wiki/Detection-algorithms)

Installation

Download node at nodejs.org and install it, if you haven't already.

npm install smart-crop --save

Usage


var smartCrop = require("smart-crop");

var foo = [];
var opencv = require('opencv');
var readFileSync = require('fs').readFileSync;

smartCrop({
  image: readFileSync(__dirname + '/test/obama.jpg'),
  width: 200,
  height: 100
}, function(err, results) {
    console.log('obama');
    // results.method === 'faces'
    console.log(
      results.method,
      results.right,
      results.bottom,
      results.left,
      results.top
    );
  });

smartCrop({
  image: readFileSync(__dirname + '/test/moon.jpg'),
  width: 200,
  height: 100
}, function(err, results) {
    console.log('moon');
    // results.method === 'good-features'
    console.log(
      results.method,
      results.right,
      results.bottom,
      results.left,
      results.top
    );
  });

Tests

npm install
npm test

Dependencies

Dev Dependencies

  • tape: tap-producing test harness for node and browsers

License

MIT

Generated by package-json-to-readme