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

smartcrop-sharp

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartcrop-sharp - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

.devcontainer/devcontainer.json

2

index.js

@@ -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 @@

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