smartcrop-sharp
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -5,3 +5,3 @@ var smartcrop = require('smartcrop'); | ||
function rgb2rgba(input) { | ||
var output = new Buffer(input.length / 3 * 4); | ||
var output = Buffer.alloc(input.length / 3 * 4); | ||
for (var i = 0; i < input.length; i += 3) { | ||
@@ -8,0 +8,0 @@ output[i / 3 * 4] = input[i]; |
{ | ||
"name": "smartcrop-sharp", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "smartcrop adapter for sharp", | ||
"types": "index.d.ts", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"scripts": { | ||
"test": "eslint index.js test/test.js && mocha --reporter spec" | ||
"test": "eslint index.js test/test.js && mocha --reporter spec && ts-node test/type-test.ts" | ||
}, | ||
@@ -12,14 +14,15 @@ "author": "Jonas Wagner <jonas@29a.ch>", | ||
"dependencies": { | ||
"smartcrop": "^2.0.2" | ||
"smartcrop": "^2.0.4" | ||
}, | ||
"peerDependencies": { | ||
"sharp": "^0.20.0" | ||
"sharp": "^0.29.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.1.2", | ||
"eslint": "^4.17.0", | ||
"mocha": "^5.0.0", | ||
"prettier-eslint": "^8.8.1", | ||
"sharp": "^0.20.0" | ||
"chai": "^4.3.4", | ||
"eslint": "^7.1.0", | ||
"mocha": "^9.1.1", | ||
"prettier-eslint": "^13.0.0", | ||
"sharp": "^0.29.0", | ||
"ts-node": "^10.2.1" | ||
} | ||
} | ||
} |
# smartcrop-sharp | ||
[![Build Status](https://travis-ci.org/jwagner/smartcrop-sharp.svg?branch=master)](https://travis-ci.org/jwagner/smartcrop-sharp) | ||
[![Tests](https://github.com/jwagner/smartcrop-sharp/actions/workflows/tests.yml/badge.svg)](https://github.com/jwagner/smartcrop-sharp/actions/workflows/tests.yml) | ||
@@ -29,21 +29,18 @@ This is an adapter module for using [smartcrop.js](https://github.com/jwagner/smartcrop.js) | ||
```javascript | ||
var request = require('request'); | ||
var sharp = require('sharp'); | ||
var smartcrop = require('smartcrop-sharp'); | ||
const sharp = require('sharp'); | ||
const smartcrop = require('smartcrop-sharp'); | ||
// finds the best crop of src and writes the cropped and resized image to dest. | ||
function applySmartCrop(src, dest, width, height) { | ||
request(src, { encoding: null }, function process(error, response, body) { | ||
if (error) return console.error(error); | ||
smartcrop.crop(body, { width: width, height: height }).then(function(result) { | ||
var crop = result.topCrop; | ||
sharp(body) | ||
return smartcrop.crop(src, { width: width, height: height }) | ||
.then(function(result) { | ||
const crop = result.topCrop; | ||
return sharp(src) | ||
.extract({ width: crop.width, height: crop.height, left: crop.x, top: crop.y }) | ||
.resize(width, height) | ||
.toFile(dest); | ||
}); | ||
}); | ||
}) | ||
} | ||
var src = 'https://raw.githubusercontent.com/jwagner/smartcrop-gm/master/test/flower.jpg'; | ||
applySmartCrop(src, 'flower-square.jpg', 128, 128); | ||
applySmartCrop('flower.jpg', 'flower-square.jpg', 128, 128); | ||
``` | ||
@@ -57,2 +54,6 @@ | ||
### 2.0.4 | ||
- Updated all dependencies | ||
- Added typescript definitions (with help from @nicholaschiang) | ||
### 2.0.2 | ||
@@ -59,0 +60,0 @@ |
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
9857
14
112
62
6
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedcolor@4.2.3(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addeddetect-libc@2.0.3(transitive)
+ Addedexpand-template@2.0.3(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedmimic-response@3.1.0(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addednapi-build-utils@1.0.2(transitive)
+ Addednode-abi@3.71.0(transitive)
+ Addednode-addon-api@4.3.0(transitive)
+ Addedprebuild-install@7.1.2(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedsharp@0.29.3(transitive)
+ Addedsimple-get@4.0.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedtar-fs@2.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedaproba@1.2.0(transitive)
- Removedare-we-there-yet@1.1.7(transitive)
- Removedbl@1.2.3(transitive)
- Removedbuffer-alloc@1.2.0(transitive)
- Removedbuffer-alloc-unsafe@1.1.0(transitive)
- Removedbuffer-fill@1.0.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedcolor@3.2.1(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedconsole-control-strings@1.1.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddecompress-response@3.3.0(transitive)
- Removeddelegates@1.0.0(transitive)
- Removedexpand-template@1.1.1(transitive)
- Removedfs-copy-file-sync@1.1.1(transitive)
- Removedfs-minipass@1.2.7(transitive)
- Removedgauge@2.7.4(transitive)
- Removedhas-unicode@2.0.1(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedmimic-response@1.0.1(transitive)
- Removedminipass@2.9.0(transitive)
- Removedminizlib@1.3.3(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removednan@2.22.0(transitive)
- Removednode-abi@2.30.1(transitive)
- Removednoop-logger@0.1.1(transitive)
- Removednpmlog@4.1.2(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedprebuild-install@4.0.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedpump@1.0.32.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedsharp@0.20.8(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedsimple-get@2.8.2(transitive)
- Removedstring-width@1.0.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedtar@4.4.19(transitive)
- Removedtar-fs@1.16.3(transitive)
- Removedtar-stream@1.6.2(transitive)
- Removedto-buffer@1.1.1(transitive)
- Removedwhich-pm-runs@1.1.0(transitive)
- Removedwide-align@1.1.5(transitive)
- Removedxtend@4.0.2(transitive)
- Removedyallist@3.1.1(transitive)
Updatedsmartcrop@^2.0.4