clevernails

1.0.0 • Public • Published

clevernails

An intelligent thumbnail generator that gets the most important part of a image based on shannon entropy.

NPM version build status npm download dependencies

Install

npm install --save clevernails

Basic Usage

var clevernails = require('clevernails');
var option = {
    input: "./test.jpg", // input image path
    output: "./output.jpg",  // output image path
    size: [500, 500]    // output image size
};
clevernails.process(option, function (err, result) {
    if (err) {
        throw err;
    }
    else {
        console.log(result);
    }
});

Notice: Input and output path is required.

output size

The following configuration about size is accepted:

Format 1: Two dimension array:

var option = {
    input: "./test.jpg", // input image path
    output: "./output.jpg",  // output image path
    size: [500, 500]    // output image size
};

Format 2: One dimension array:

var option = {
    input: "./test.jpg", // input image path
    output: "./output.jpg",  // output image path
    size: [500]    // output image size
};

size will be interpreted as [500, 500]in this example.

Format 3: A single number:

var option = {
    input: "./test.jpg", // input image path
    output: "./output.jpg",  // output image path
    size: 500    // output image size
};

size will be intepreted as [500, 500]in this example.

Format 4: multiple dimension array (dimension > 2):

var option = {
    input: "./test.jpg", // input image path
    output: "./output.jpg",  // output image path
    size: [300, 400, 500]    // output image size
};

size will be intepreted as [300, 400]in this example.

Contributors

License

MIT

Package Sidebar

Install

npm i clevernails

Weekly Downloads

12

Version

1.0.0

License

MIT

Last publish

Collaborators

  • heavenduke