Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smartcrop

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartcrop - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.gitattributes

12

package.json
{
"name": "smartcrop",
"version": "1.0.0",
"version": "1.1.0",
"description": "Content aware image cropping.",

@@ -16,4 +16,9 @@ "homepage": "https://github.com/jwagner/smartcrop.js",

"grunt-rsync": "~0.5.0",
"karma": "^1.1.0",
"karma-chrome-launcher": "^1.0.1",
"karma-mocha": "^1.1.1",
"karma-sauce-launcher": "^1.0.0",
"microtime": "^2.0.0",
"mocha": "^1.18.2"
"mocha": "^1.18.2",
"promise-polyfill": "^5.2.1"
},

@@ -24,3 +29,6 @@ "license": "MIT",

"url": "https://github.com/jwagner/smartcrop.js.git"
},
"scripts": {
"test": "./node_modules/.bin/karma start karma.conf.js"
}
}
# smartcrop.js
[![Build Status](https://travis-ci.org/jwagner/smartcrop.js.svg?branch=travis)](https://travis-ci.org/jwagner/smartcrop.js)
Smartcrop.js implements an algorithm to find good crops for images.

@@ -159,2 +161,5 @@ It can be used in the browser, in node or via a CLI.

### 1.1
Creating github releases. Added options.input which is getting passed along to iop.open.
### 1.0

@@ -161,0 +166,0 @@ Refactoring/cleanup to make it easier to use with node.js (dropping the node-canvas dependency) and enable support for boosts which can be used to do face detection.

20

smartcrop.js

@@ -91,3 +91,3 @@ /**

return iop.open(inputImage).then(function(image) {
return iop.open(inputImage, options.input).then(function(image) {

@@ -400,19 +400,2 @@ if (options.width && options.height) {

function downSampleCanvas(input, factor) {
var c = document.createElement('canvas');
c.width = input.width;
c.height = input.height;
var ctx = c.getContext('2d');
var id = ctx.createImageData(c.width, c.height);
id.data.set(input.data);
for (var i = 0; i < id.data.length; i += 4) {
id.data[i + 3] = 255;
}
ctx.putImageData(id, 0, 0);
var w = Math.ceil(input.width / factor);
var h = Math.ceil(input.height / factor);
ctx.drawImage(c, 0, 0, input.width, input.height, 0, 0, w, h);
return ctx.getImageData(0, 0, w, h);
}
function downSample(input, factor) {

@@ -511,2 +494,3 @@ var idata = input.data;

}
smartcrop._canvasImageOperations = canvasImageOperations;

@@ -513,0 +497,0 @@ // Aliases and helpers

(function() {
mocha.setup('bdd');
var expect = chai.expect;
var KITTY = '/examples/images/flickr/kitty.jpg';

@@ -48,3 +51,3 @@ describe('smartcrop', function() {

it('should take into account boost', function() {
var boost = [{x : img.width - 128, y: img.height - 128, width: 64, height: 64, weight: 1.0}];
var boost = [{x: img.width - 128, y: img.height - 128, width: 64, height: 64, weight: 1.0}];
console.log(img.width, img.height);

@@ -65,2 +68,24 @@ return smartcrop.crop(img, {boost: boost}, function(result) {

});
describe('iop', function() {
describe('open', function() {
it('passes input options', function() {
var iop = smartcrop._canvasImageOperations(smartcrop.DEFAULTS.canvasFactory);
var open = iop.open;
var inputOptions;
iop.open = function(image, inputOptions_) {
inputOptions = inputOptions_;
return open(image);
};
var options = {
imageOperations: iop,
input: {foo: 'bar'}
};
return smartcrop.crop(img, options, function(result) {
expect(inputOptions).to.equal(options.input);
validResult(result);
});
});
});
});
describe('_downSample', function() {

@@ -67,0 +92,0 @@ var input = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc