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

sharp

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sharp - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

5

index.js
var sharp = require("./build/Release/sharp");
module.exports.buffer = {
jpeg: "__jpeg",
png: "__png"
};
module.exports.crop = function(input, output, width, height, callback) {

@@ -4,0 +9,0 @@ sharp.resize(input, output, width, height, "c", callback);

5

package.json
{
"name": "sharp",
"version": "0.0.6",
"version": "0.0.7",
"author": "Lovell Fuller",

@@ -23,3 +23,4 @@ "description": "High performance module to resize JPEG and PNG images using the libvips image processing library",

"libvips",
"fast"
"fast",
"buffer"
],

@@ -26,0 +27,0 @@ "devDependencies": {

68

README.md

@@ -36,8 +36,6 @@ # sharp

### crop(inputPath, outputPath, width, height, callback)
### crop(input, output, width, height, callback)
Scale and crop `inputPath` to `width` x `height` and write to `outputPath` calling `callback` when complete.
Scale and crop to `width` x `height` calling `callback` when complete.
Example:
```javascript

@@ -53,8 +51,26 @@ sharp.crop("input.jpg", "output.jpg", 300, 200, function(err) {

### embedWhite(inputPath, outputPath, width, height, callback)
```javascript
sharp.crop("input.jpg", sharp.buffer.jpeg, 300, 200, function(err, buffer) {
if (err) {
throw err;
}
// buffer contains JPEG image data
});
```
Scale and embed `inputPath` to `width` x `height` using a white canvas and write to `outputPath` calling `callback` when complete.
```javascript
sharp.crop("input.jpg", sharp.buffer.png, 300, 200, function(err, buffer) {
if (err) {
throw err;
}
// buffer contains PNG image data (converted from JPEG)
});
```
### embedWhite(input, output, width, height, callback)
Scale and embed to `width` x `height` using a white canvas calling `callback` when complete.
```javascript
sharp.embedWhite("input.jpg", "output.png", 200, 300, function(err) {
sharp.embedWhite("input.jpg", "output.jpg", 200, 300, function(err) {
if (err) {

@@ -68,6 +84,15 @@ throw err;

### embedBlack(inputPath, outputPath, width, height, callback)
```javascript
sharp.embedWhite("input.jpg", sharp.buffer.jpeg, 200, 300, function(err, buffer) {
if (err) {
throw err;
}
// buffer contains JPEG image data
});
```
Scale and embed `inputPath` to `width` x `height` using a black canvas and write to `outputPath` calling `callback` when complete.
### embedBlack(input, output, width, height, callback)
Scale and embed to `width` x `height` using a black canvas calling `callback` when complete.
```javascript

@@ -83,2 +108,15 @@ sharp.embedBlack("input.png", "output.png", 200, 300, function(err) {

### Parameters common to all methods
#### input
String containing the filename to read from.
#### output
One of:
* String containing the filename to write to.
* `sharp.buffer.jpeg` to pass a Buffer containing JPEG image data to `callback`.
* `sharp.buffer.png` to pass a Buffer containing PNG image data to `callback`.
## Testing

@@ -93,4 +131,4 @@

* AMD Athlon 4 core 3.3GHz 512KB L2 CPU 1333 DDR3
* libvips 7.36
* libjpeg-turbo8 1.2.1
* libvips 7.37
* libjpeg-turbo8 1.3.0
* libpng 1.6.6

@@ -104,3 +142,4 @@ * zlib1g 1.2.7

* epeg x 28.07 ops/sec ±0.07% (70 runs sampled)
* sharp x 31.60 ops/sec ±8.80% (80 runs sampled)
* sharp-file x 31.60 ops/sec ±8.80% (80 runs sampled)
* sharp-buffer x 34.04 ops/sec ±0.36% (82 runs sampled)

@@ -111,7 +150,8 @@ #### PNG

* gm x 21.65 ops/sec ±0.18% (56 runs sampled)
* sharp x 39.47 ops/sec ±6.78% (68 runs sampled)
* sharp-file x 39.47 ops/sec ±6.78% (68 runs sampled)
* sharp-buffer x 42.87 ops/sec ±0.19% (71 runs sampled)
## Licence
Copyright 2013 Lovell Fuller
Copyright 2013, 2014 Lovell Fuller

@@ -118,0 +158,0 @@ Licensed under the Apache License, Version 2.0 (the "License");

@@ -11,5 +11,7 @@ var sharp = require("../index");

var outputJpg = __dirname + "/output.jpg";
var outputJpgLength = 47035;
var inputPng = __dirname + "/50020484-00001.png"; // http://c.searspartsdirect.com/lis_png/PLDM/50020484-00001.png
var outputPng = __dirname + "/output.png";
var outputPngLength = 60379;

@@ -22,4 +24,4 @@ var width = 640;

(new Benchmark.Suite("jpeg")).add("imagemagick", {
"defer": true,
"fn": function(deferred) {
defer: true,
fn: function(deferred) {
imagemagick.resize({

@@ -40,4 +42,4 @@ srcPath: inputJpg,

}).add("gm", {
"defer": true,
"fn": function(deferred) {
defer: true,
fn: function(deferred) {
gm(inputJpg).crop(width, height).quality(80).write(outputJpg, function (err) {

@@ -52,4 +54,4 @@ if (err) {

}).add("epeg", {
"defer": true,
"fn": function(deferred) {
defer: true,
fn: function(deferred) {
var image = new epeg.Image({path: inputJpg});

@@ -59,5 +61,5 @@ image.downsize(width, height, 80).saveTo(outputJpg);

}
}).add("sharp", {
"defer": true,
"fn": function(deferred) {
}).add("sharp-file", {
defer: true,
fn: function(deferred) {
sharp.crop(inputJpg, outputJpg, width, height, function(err) {

@@ -71,2 +73,15 @@ if (err) {

}
}).add("sharp-buffer", {
defer: true,
fn: function(deferred) {
sharp.crop(inputJpg, sharp.buffer.jpeg, width, height, function(err, buffer) {
if (err) {
throw err;
} else {
assert.notStrictEqual(null, buffer);
assert.strictEqual(outputJpgLength, buffer.length);
deferred.resolve();
}
});
}
}).on("cycle", function(event) {

@@ -80,4 +95,4 @@ console.log("jpeg " + String(event.target));

(new Benchmark.Suite("png")).add("imagemagick", {
"defer": true,
"fn": function(deferred) {
defer: true,
fn: function(deferred) {
imagemagick.resize({

@@ -97,4 +112,4 @@ srcPath: inputPng,

}).add("gm", {
"defer": true,
"fn": function(deferred) {
defer: true,
fn: function(deferred) {
gm(inputPng).crop(width, height).write(outputPng, function (err) {

@@ -108,5 +123,5 @@ if (err) {

}
}).add("sharp", {
"defer": true,
"fn": function(deferred) {
}).add("sharp-file", {
defer: true,
fn: function(deferred) {
sharp.crop(inputPng, outputPng, width, height, function(err) {

@@ -120,2 +135,15 @@ if (err) {

}
}).add("sharp-buffer", {
defer: true,
fn: function(deferred) {
sharp.crop(inputPng, sharp.buffer.png, width, height, function(err, buffer) {
if (err) {
throw err;
} else {
assert.notStrictEqual(null, buffer);
assert.strictEqual(outputPngLength, buffer.length);
deferred.resolve();
}
});
}
}).on("cycle", function(event) {

@@ -130,4 +158,4 @@ console.log(" png " + String(event.target));

Object.keys(results).forEach(function(format) {
assert(results[format] == "sharp", "sharp was slower than " + results[format] + " for " + format);
assert.strictEqual("sharp", results[format].toString().substr(0, 5), "sharp was slower than " + results[format] + " for " + format);
});
});

Sorry, the diff of this file is not supported yet

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