mirror of
https://github.com/lovell/sharp.git
synced 2026-02-05 06:06:18 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
daeebcc7dc | ||
|
|
5546a4f881 | ||
|
|
4aee725530 | ||
|
|
f3da2284b1 | ||
|
|
f3cd263cb7 | ||
|
|
8443dd5122 |
28
README.md
28
README.md
@@ -13,22 +13,20 @@ It is somewhat opinionated in that it only deals with JPEG images, always obeys
|
|||||||
|
|
||||||
Under the hood you'll find the blazingly fast [libvips](https://github.com/jcupitt/libvips) image processing library, originally created in 1989 at Birkbeck College and currently maintained by the University of Southampton.
|
Under the hood you'll find the blazingly fast [libvips](https://github.com/jcupitt/libvips) image processing library, originally created in 1989 at Birkbeck College and currently maintained by the University of Southampton.
|
||||||
|
|
||||||
Performance is 4x-8x faster than the imagemagick equivalent, based mainly on the number of CPU cores available.
|
Performance is 4x-8x faster than ImageMagick and 2x-4x faster than GraphicsMagick, based mainly on the number of CPU cores available.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
Requires Node.js v0.8+, node-gyp and libvips-dev to build.
|
* Node.js v0.8+
|
||||||
|
* node-gyp
|
||||||
|
* libvips-dev 7.28+
|
||||||
|
|
||||||
sudo npm install -g node-gyp
|
```
|
||||||
sudo apt-get install libvips-dev
|
sudo npm install -g node-gyp
|
||||||
|
sudo apt-get install libvips-dev
|
||||||
|
```
|
||||||
|
|
||||||
Requires vips-7.xx.pc (installed with libvips-dev) to be symlinked as /usr/lib/pkgconfig/vips.pc
|
When installed as a package, please symlink `vips-7.28.pc` (or later, installed with libvips-dev) as `/usr/lib/pkgconfig/vips.pc`. To do this in Ubuntu 13.04 (64-bit), use:
|
||||||
|
|
||||||
Ubuntu 12.04 LTS:
|
|
||||||
|
|
||||||
sudo ln -s /usr/lib/pkgconfig/vips-7.26.pc /usr/lib/pkgconfig/vips.pc
|
|
||||||
|
|
||||||
Ubuntu 13.04 (64-bit):
|
|
||||||
|
|
||||||
sudo ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/vips-7.28.pc /usr/lib/pkgconfig/vips.pc
|
sudo ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/vips-7.28.pc /usr/lib/pkgconfig/vips.pc
|
||||||
|
|
||||||
@@ -84,7 +82,7 @@ sharp.embedBlack("input.jpg", "output.jpg", 200, 300, function(err) {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## Testing [](https://travis-ci.org/lovell/sharp)
|
## Testing
|
||||||
|
|
||||||
npm install --dev sharp
|
npm install --dev sharp
|
||||||
npm test
|
npm test
|
||||||
@@ -93,8 +91,10 @@ sharp.embedBlack("input.jpg", "output.jpg", 200, 300, function(err) {
|
|||||||
|
|
||||||
### AMD Athlon 4x core 3.3GHz 512KB L2
|
### AMD Athlon 4x core 3.3GHz 512KB L2
|
||||||
|
|
||||||
* imagemagick x 5.55 ops/sec ±0.68% (31 runs sampled)
|
* imagemagick x 5.55 ops/sec ±0.45% (31 runs sampled)
|
||||||
* sharp x 24.49 ops/sec ±6.85% (64 runs sampled)
|
* gm x 10.31 ops/sec ±3.57% (53 runs sampled)
|
||||||
|
* epeg x 27.79 ops/sec ±0.12% (69 runs sampled)
|
||||||
|
* sharp x 31.52 ops/sec ±8.74% (80 runs sampled)
|
||||||
|
|
||||||
### AWS t1.micro
|
### AWS t1.micro
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sharp",
|
"name": "sharp",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"description": "High performance Node.js module to resize JPEG images using the libvips image processing library",
|
"description": "High performance Node.js module to resize JPEG images using the libvips image processing library",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -9,6 +9,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"imagemagick": "*",
|
"imagemagick": "*",
|
||||||
|
"gm": "*",
|
||||||
|
"epeg": "*",
|
||||||
"benchmark": "*"
|
"benchmark": "*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void ResizeAsync(uv_work_t *work) {
|
|||||||
ResizeBaton* baton = static_cast<ResizeBaton*>(work->data);
|
ResizeBaton* baton = static_cast<ResizeBaton*>(work->data);
|
||||||
|
|
||||||
VipsImage *in = vips_image_new_mode((baton->src).c_str(), "p");
|
VipsImage *in = vips_image_new_mode((baton->src).c_str(), "p");
|
||||||
im_jpeg2vips((baton->src).c_str(), in);
|
vips_jpegload((baton->src).c_str(), &in, NULL);
|
||||||
if (in == NULL) {
|
if (in == NULL) {
|
||||||
(baton->err).append(vips_error_buffer());
|
(baton->err).append(vips_error_buffer());
|
||||||
vips_error_clear();
|
vips_error_clear();
|
||||||
@@ -114,10 +114,10 @@ void ResizeAsync(uv_work_t *work) {
|
|||||||
}
|
}
|
||||||
img = t[3];
|
img = t[3];
|
||||||
|
|
||||||
if (im_vips2jpeg(img, baton->dst.c_str())) {
|
if (vips_jpegsave(img, baton->dst.c_str(), "Q", 80, "profile", "none", "optimize_coding", TRUE, NULL)) {
|
||||||
(baton->err).append(vips_error_buffer());
|
(baton->err).append(vips_error_buffer());
|
||||||
vips_error_clear();
|
vips_error_clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResizeAsyncAfter(uv_work_t *work, int status) {
|
void ResizeAsyncAfter(uv_work_t *work, int status) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
var sharp = require("../index");
|
var sharp = require("../index");
|
||||||
var imagemagick = require("imagemagick");
|
var imagemagick = require("imagemagick");
|
||||||
|
var gm = require("gm");
|
||||||
|
var epeg = require("epeg");
|
||||||
var assert = require("assert");
|
var assert = require("assert");
|
||||||
var Benchmark = require("benchmark");
|
var Benchmark = require("benchmark");
|
||||||
|
|
||||||
@@ -26,6 +28,24 @@ suite.add("imagemagick", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}).add("gm", {
|
||||||
|
"defer": true,
|
||||||
|
"fn": function(deferred) {
|
||||||
|
gm(input).crop(width, height).write(output, function (err) {
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
} else {
|
||||||
|
deferred.resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).add("epeg", {
|
||||||
|
"defer": true,
|
||||||
|
"fn": function(deferred) {
|
||||||
|
var image = new epeg.Image({path: input});
|
||||||
|
image.downsize(width, height).saveTo(output);
|
||||||
|
deferred.resolve();
|
||||||
|
}
|
||||||
}).add("sharp", {
|
}).add("sharp", {
|
||||||
"defer": true,
|
"defer": true,
|
||||||
"fn": function(deferred) {
|
"fn": function(deferred) {
|
||||||
|
|||||||
Reference in New Issue
Block a user