mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Remove use of deprecated API from benchmark
Add mapnik as possible contender
This commit is contained in:
parent
a7b024d4fa
commit
945706c2a4
@ -9,16 +9,17 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"async": "^2.1.1",
|
"async": "^2.1.1",
|
||||||
"benchmark": "^2.1.1",
|
"benchmark": "^2.1.2",
|
||||||
"gm": "^1.23.0",
|
"gm": "^1.23.0",
|
||||||
"imagemagick": "^0.1.3",
|
"imagemagick": "^0.1.3",
|
||||||
"imagemagick-native": "^1.9.3",
|
"imagemagick-native": "^1.9.3",
|
||||||
"jimp": "^0.2.27",
|
"jimp": "^0.2.27",
|
||||||
"lwip": "^0.0.9",
|
"lwip": "^0.0.9",
|
||||||
|
"mapnik": "^3.5.14",
|
||||||
"semver": "^5.3.0"
|
"semver": "^5.3.0"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ process.env.UV_THREADPOOL_SIZE = 64;
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
|
|
||||||
const sharp = require('../../index');
|
const sharp = require('../../');
|
||||||
const fixtures = require('../fixtures');
|
const fixtures = require('../fixtures');
|
||||||
|
|
||||||
const width = 720;
|
const width = 720;
|
||||||
|
@ -9,6 +9,7 @@ const Benchmark = require('benchmark');
|
|||||||
// Contenders
|
// Contenders
|
||||||
const gm = require('gm');
|
const gm = require('gm');
|
||||||
const imagemagick = require('imagemagick');
|
const imagemagick = require('imagemagick');
|
||||||
|
const mapnik = require('mapnik');
|
||||||
const jimp = require('jimp');
|
const jimp = require('jimp');
|
||||||
const sharp = require('../../');
|
const sharp = require('../../');
|
||||||
let imagemagickNative;
|
let imagemagickNative;
|
||||||
@ -125,6 +126,38 @@ async.series({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// mapnik
|
||||||
|
jpegSuite.add('mapnik-file-file', {
|
||||||
|
defer: true,
|
||||||
|
fn: function (deferred) {
|
||||||
|
mapnik.Image.open(fixtures.inputJpg, function (err, img) {
|
||||||
|
if (err) throw err;
|
||||||
|
img
|
||||||
|
.resize(width, height, {
|
||||||
|
scaling_method: mapnik.imageScaling.lanczos
|
||||||
|
})
|
||||||
|
.save(fixtures.outputJpg, 'jpeg:quality=80', function (err) {
|
||||||
|
if (err) throw err;
|
||||||
|
deferred.resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).add('mapnik-buffer-buffer', {
|
||||||
|
defer: true,
|
||||||
|
fn: function (deferred) {
|
||||||
|
mapnik.Image.fromBytes(inputJpgBuffer, function (err, img) {
|
||||||
|
if (err) throw err;
|
||||||
|
img
|
||||||
|
.resize(width, height, {
|
||||||
|
scaling_method: mapnik.imageScaling.lanczos
|
||||||
|
})
|
||||||
|
.encode('jpeg:quality=80', function (err) {
|
||||||
|
if (err) throw err;
|
||||||
|
deferred.resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
// imagemagick
|
// imagemagick
|
||||||
jpegSuite.add('imagemagick-file-file', {
|
jpegSuite.add('imagemagick-file-file', {
|
||||||
defer: true,
|
defer: true,
|
||||||
@ -174,8 +207,8 @@ async.series({
|
|||||||
defer: true,
|
defer: true,
|
||||||
fn: function (deferred) {
|
fn: function (deferred) {
|
||||||
gm(inputJpgBuffer)
|
gm(inputJpgBuffer)
|
||||||
.resize(width, height)
|
|
||||||
.filter('Lanczos')
|
.filter('Lanczos')
|
||||||
|
.resize(width, height)
|
||||||
.quality(80)
|
.quality(80)
|
||||||
.write(fixtures.outputJpg, function (err) {
|
.write(fixtures.outputJpg, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -189,8 +222,8 @@ async.series({
|
|||||||
defer: true,
|
defer: true,
|
||||||
fn: function (deferred) {
|
fn: function (deferred) {
|
||||||
gm(inputJpgBuffer)
|
gm(inputJpgBuffer)
|
||||||
.resize(width, height)
|
|
||||||
.filter('Lanczos')
|
.filter('Lanczos')
|
||||||
|
.resize(width, height)
|
||||||
.quality(80)
|
.quality(80)
|
||||||
.toBuffer(function (err, buffer) {
|
.toBuffer(function (err, buffer) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -205,8 +238,8 @@ async.series({
|
|||||||
defer: true,
|
defer: true,
|
||||||
fn: function (deferred) {
|
fn: function (deferred) {
|
||||||
gm(fixtures.inputJpg)
|
gm(fixtures.inputJpg)
|
||||||
.resize(width, height)
|
|
||||||
.filter('Lanczos')
|
.filter('Lanczos')
|
||||||
|
.resize(width, height)
|
||||||
.quality(80)
|
.quality(80)
|
||||||
.write(fixtures.outputJpg, function (err) {
|
.write(fixtures.outputJpg, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -220,8 +253,8 @@ async.series({
|
|||||||
defer: true,
|
defer: true,
|
||||||
fn: function (deferred) {
|
fn: function (deferred) {
|
||||||
gm(fixtures.inputJpg)
|
gm(fixtures.inputJpg)
|
||||||
.resize(width, height)
|
|
||||||
.filter('Lanczos')
|
.filter('Lanczos')
|
||||||
|
.resize(width, height)
|
||||||
.quality(80)
|
.quality(80)
|
||||||
.toBuffer(function (err, buffer) {
|
.toBuffer(function (err, buffer) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -447,7 +480,7 @@ async.series({
|
|||||||
fn: function (deferred) {
|
fn: function (deferred) {
|
||||||
sharp(inputJpgBuffer)
|
sharp(inputJpgBuffer)
|
||||||
.resize(width, height)
|
.resize(width, height)
|
||||||
.progressive()
|
.jpeg({ progressive: true })
|
||||||
.toBuffer(function (err, buffer) {
|
.toBuffer(function (err, buffer) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
@ -462,7 +495,7 @@ async.series({
|
|||||||
fn: function (deferred) {
|
fn: function (deferred) {
|
||||||
sharp(inputJpgBuffer)
|
sharp(inputJpgBuffer)
|
||||||
.resize(width, height)
|
.resize(width, height)
|
||||||
.withoutChromaSubsampling()
|
.jpeg({ chromaSubsampling: '4:4:4' })
|
||||||
.toBuffer(function (err, buffer) {
|
.toBuffer(function (err, buffer) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
@ -674,6 +707,52 @@ async.series({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// mapnik
|
||||||
|
pngSuite.add('mapnik-file-file', {
|
||||||
|
defer: true,
|
||||||
|
fn: function (deferred) {
|
||||||
|
mapnik.Image.open(fixtures.inputPng, function (err, img) {
|
||||||
|
if (err) throw err;
|
||||||
|
img.premultiply(function (err, img) {
|
||||||
|
if (err) throw err;
|
||||||
|
img.resize(width, height, {
|
||||||
|
scaling_method: mapnik.imageScaling.lanczos
|
||||||
|
}, function (err, img) {
|
||||||
|
if (err) throw err;
|
||||||
|
img.demultiply(function (err, img) {
|
||||||
|
if (err) throw err;
|
||||||
|
img.save(fixtures.outputPng, 'png', function (err) {
|
||||||
|
if (err) throw err;
|
||||||
|
deferred.resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).add('mapnik-buffer-buffer', {
|
||||||
|
defer: true,
|
||||||
|
fn: function (deferred) {
|
||||||
|
mapnik.Image.fromBytes(inputPngBuffer, function (err, img) {
|
||||||
|
if (err) throw err;
|
||||||
|
img.premultiply(function (err, img) {
|
||||||
|
if (err) throw err;
|
||||||
|
img.resize(width, height, {
|
||||||
|
scaling_method: mapnik.imageScaling.lanczos
|
||||||
|
}, function (err, img) {
|
||||||
|
if (err) throw err;
|
||||||
|
img.demultiply(function (err, img) {
|
||||||
|
if (err) throw err;
|
||||||
|
img.encode('png', function (err) {
|
||||||
|
if (err) throw err;
|
||||||
|
deferred.resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
// imagemagick
|
// imagemagick
|
||||||
pngSuite.add('imagemagick-file-file', {
|
pngSuite.add('imagemagick-file-file', {
|
||||||
defer: true,
|
defer: true,
|
||||||
@ -714,8 +793,8 @@ async.series({
|
|||||||
defer: true,
|
defer: true,
|
||||||
fn: function (deferred) {
|
fn: function (deferred) {
|
||||||
gm(fixtures.inputPng)
|
gm(fixtures.inputPng)
|
||||||
.resize(width, height)
|
|
||||||
.filter('Lanczos')
|
.filter('Lanczos')
|
||||||
|
.resize(width, height)
|
||||||
.write(fixtures.outputPng, function (err) {
|
.write(fixtures.outputPng, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
@ -728,8 +807,8 @@ async.series({
|
|||||||
defer: true,
|
defer: true,
|
||||||
fn: function (deferred) {
|
fn: function (deferred) {
|
||||||
gm(fixtures.inputPng)
|
gm(fixtures.inputPng)
|
||||||
.resize(width, height)
|
|
||||||
.filter('Lanczos')
|
.filter('Lanczos')
|
||||||
|
.resize(width, height)
|
||||||
.toBuffer(function (err, buffer) {
|
.toBuffer(function (err, buffer) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
@ -800,7 +879,7 @@ async.series({
|
|||||||
fn: function (deferred) {
|
fn: function (deferred) {
|
||||||
sharp(inputPngBuffer)
|
sharp(inputPngBuffer)
|
||||||
.resize(width, height)
|
.resize(width, height)
|
||||||
.progressive()
|
.png({ progressive: true })
|
||||||
.toBuffer(function (err, buffer) {
|
.toBuffer(function (err, buffer) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
@ -815,7 +894,7 @@ async.series({
|
|||||||
fn: function (deferred) {
|
fn: function (deferred) {
|
||||||
sharp(inputPngBuffer)
|
sharp(inputPngBuffer)
|
||||||
.resize(width, height)
|
.resize(width, height)
|
||||||
.withoutAdaptiveFiltering()
|
.png({ adaptiveFiltering: false })
|
||||||
.toBuffer(function (err, buffer) {
|
.toBuffer(function (err, buffer) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -5,7 +5,7 @@ const gm = require('gm');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const Benchmark = require('benchmark');
|
const Benchmark = require('benchmark');
|
||||||
|
|
||||||
const sharp = require('../../index');
|
const sharp = require('../../');
|
||||||
const fixtures = require('../fixtures');
|
const fixtures = require('../fixtures');
|
||||||
|
|
||||||
sharp.cache(false);
|
sharp.cache(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user