Compare commits

..

4 Commits

Author SHA1 Message Date
Lovell Fuller
0b7c8661fb The pkgconfig data file ends up in /usr/local when compiling libvips from source 2013-09-23 21:40:01 +01:00
Lovell Fuller
30f75bcc56 Additional performance test stats 2013-08-29 22:55:42 +01:00
Lovell Fuller
6f5125e889 Corrected order of width and height in usage docs 2013-08-26 16:21:38 +01:00
Lovell Fuller
6e3f9b04de Corrected order of width and height in usage docs 2013-08-26 16:20:43 +01:00
3 changed files with 37 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
# sharp # sharp
_adj_ _adj_
@@ -7,17 +7,17 @@ _adj_
3. shrewd or astute: a sharp bargainer. 3. shrewd or astute: a sharp bargainer.
4. (Informal.) very stylish: a sharp dresser; a sharp jacket. 4. (Informal.) very stylish: a sharp dresser; a sharp jacket.
The typical use case for this high performance Node.js module is to convert a large JPEG image to smaller JPEG images of varying dimensions. The typical use case for this high speed Node.js module is to convert a large JPEG image to smaller JPEG images of varying dimensions.
It is somewhat opinionated in that it only deals with JPEG images, always obeys the requested dimensions by either cropping or embedding and insists on a mild sharpen of the resulting image. It is somewhat opinionated in that it only deals with JPEG images, always obeys the requested dimensions by either cropping or embedding and insists on a mild sharpen of the resulting image.
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.
Speed is typically 4x faster than the imagemagick equivalent. Performance is 4x-8x faster than the imagemagick equivalent, based mainly on the number of CPU cores available.
## Prerequisites ## Prerequisites
Requires node-gyp and libvips-dev to build. Requires Node.js v0.8+, node-gyp and libvips-dev to build.
sudo npm install -g node-gyp sudo npm install -g node-gyp
sudo apt-get install libvips-dev sudo apt-get install libvips-dev
@@ -38,7 +38,7 @@ Ubuntu 13.04 (64-bit):
## Usage ## Usage
var sharp = require("sharp"); var sharp = require("sharp");
### crop(inputPath, outputPath, width, height, callback) ### crop(inputPath, outputPath, width, height, callback)
@@ -65,7 +65,7 @@ sharp.embedWhite("input.jpg", "output.jpg", 200, 300, function(err) {
if (err) { if (err) {
throw err; throw err;
} }
// output.jpg is a 300 pixels wide and 200 pixels high image // output.jpg is a 200 pixels wide and 300 pixels high image
// containing a scaled version of input.jpg embedded on a white canvas // containing a scaled version of input.jpg embedded on a white canvas
}); });
``` ```
@@ -79,18 +79,39 @@ sharp.embedBlack("input.jpg", "output.jpg", 200, 300, function(err) {
if (err) { if (err) {
throw err; throw err;
} }
// output.jpg is a 300 pixels wide and 200 pixels high image // output.jpg is a 200 pixels wide and 300 pixels high image
// containing a scaled version of input.jpg embedded on a black canvas // containing a scaled version of input.jpg embedded on a black canvas
}); });
``` ```
## Testing [![Build Status](https://travis-ci.org/lovell/sharp.png?branch=master)](https://travis-ci.org/lovell/sharp) ## Testing [![Build Status](https://travis-ci.org/lovell/sharp.png?branch=master)](https://travis-ci.org/lovell/sharp)
npm install --dev sharp
npm test npm test
## Performance ## Performance
Using an AMD Athlon quad core CPU with 512KB L2 cache clocked at 3.3GHz with 8GB RAM: ### AMD Athlon 4x core 3.3GHz 512KB L2
* imagemagick x 5.55 ops/sec <EFBFBD>0.68% (31 runs sampled) * imagemagick x 5.55 ops/sec ±0.68% (31 runs sampled)
* sharp x 24.49 ops/sec <EFBFBD>6.85% (64 runs sampled) * sharp x 24.49 ops/sec ±6.85% (64 runs sampled)
### AWS t1.micro
* imagemagick x 1.36 ops/sec ±0.96% (11 runs sampled)
* sharp x 12.42 ops/sec ±5.84% (64 runs sampled)
### AWS m1.medium
* imagemagick x 1.38 ops/sec ±0.45% (11 runs sampled)
* sharp x 12.66 ops/sec ±5.54% (65 runs sampled)
### AWS c1.medium
* imagemagick x 2.10 ops/sec ±0.67% (15 runs sampled)
* sharp x 18.97 ops/sec ±10.54% (52 runs sampled)
### AWS m3.xlarge
* imagemagick x 4.46 ops/sec ±0.33% (26 runs sampled)
* sharp x 28.89 ops/sec ±7.75% (74 runs sampled)

View File

@@ -2,7 +2,10 @@
'targets': [{ 'targets': [{
'target_name': 'sharp', 'target_name': 'sharp',
'sources': ['src/sharp.cc'], 'sources': ['src/sharp.cc'],
'libraries': ['<!@(PKG_CONFIG_PATH="/usr/lib/pkgconfig" pkg-config --libs glib-2.0 vips)'], 'libraries': [
'<!@(PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" pkg-config --libs vips)',
'<!@(PKG_CONFIG_PATH="/usr/lib/pkgconfig" pkg-config --libs vips)'
],
'include_dirs': [ 'include_dirs': [
'/usr/include/glib-2.0', '/usr/include/glib-2.0',
'/usr/lib/glib-2.0/include', '/usr/lib/glib-2.0/include',

View File

@@ -1,6 +1,6 @@
{ {
"name": "sharp", "name": "sharp",
"version": "0.0.2", "version": "0.0.3",
"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": {
@@ -15,7 +15,7 @@
"test": "node tests/perf.js" "test": "node tests/perf.js"
}, },
"engines": { "engines": {
"node": "*" "node": ">=0.8"
}, },
"keywords": [ "keywords": [
"jpeg", "jpeg",