Comparing version 1.0.0 to 1.1.0
{ | ||
"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. |
@@ -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 = { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32282131
79
790
171
35
14