mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Test: update benchmark dependencies
This commit is contained in:
parent
a532659b0f
commit
802f560b9b
@ -8,7 +8,7 @@
|
||||
"test": "node perf && node random && node parallel"
|
||||
},
|
||||
"dependencies": {
|
||||
"@squoosh/cli": "0.7.2",
|
||||
"@squoosh/cli": "0.7.3",
|
||||
"@squoosh/lib": "0.4.0",
|
||||
"async": "3.2.4",
|
||||
"benchmark": "2.1.4",
|
||||
@ -18,7 +18,7 @@
|
||||
"semver": "7.3.8"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@tensorflow/tfjs-node": "4.1.0",
|
||||
"@tensorflow/tfjs-node": "4.2.0",
|
||||
"mapnik": "4.5.9"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
|
@ -32,6 +32,7 @@ const outputWebP = fixtures.path('output.webp');
|
||||
|
||||
const width = 720;
|
||||
const height = 588;
|
||||
const heightPng = 540;
|
||||
|
||||
// Disable libvips cache to ensure tests are as fair as they can be
|
||||
sharp.cache(false);
|
||||
@ -648,7 +649,7 @@ async.series({
|
||||
throw err;
|
||||
} else {
|
||||
image
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.deflateLevel(6)
|
||||
.filterType(0)
|
||||
.getBuffer(jimp.MIME_PNG, function (err) {
|
||||
@ -669,7 +670,7 @@ async.series({
|
||||
throw err;
|
||||
} else {
|
||||
image
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.deflateLevel(6)
|
||||
.filterType(0)
|
||||
.write(outputPng, function (err) {
|
||||
@ -683,6 +684,59 @@ async.series({
|
||||
});
|
||||
}
|
||||
});
|
||||
// squoosh-cli
|
||||
pngSuite.add('squoosh-cli-file-file', {
|
||||
defer: true,
|
||||
fn: function (deferred) {
|
||||
exec(`./node_modules/.bin/squoosh-cli \
|
||||
--output-dir ${os.tmpdir()} \
|
||||
--resize '{"enabled":true,"width":${width},"height":${heightPng},"method":"lanczos3","premultiply":true,"linearRGB":false}' \
|
||||
--oxipng '{"level":1}' \
|
||||
"${fixtures.inputPngAlphaPremultiplicationLarge}"`, function (err) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
deferred.resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
// squoosh-lib (GPLv3)
|
||||
pngSuite.add('squoosh-lib-buffer-buffer', {
|
||||
defer: true,
|
||||
fn: function (deferred) {
|
||||
const pool = new squoosh.ImagePool();
|
||||
const image = pool.ingestImage(inputPngBuffer);
|
||||
image.decoded
|
||||
.then(function () {
|
||||
return image.preprocess({
|
||||
resize: {
|
||||
enabled: true,
|
||||
width,
|
||||
height: heightPng,
|
||||
method: 'lanczos3',
|
||||
premultiply: true,
|
||||
linearRGB: false
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(function () {
|
||||
return image.encode({
|
||||
oxipng: {
|
||||
level: 1
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(function () {
|
||||
return pool.close();
|
||||
})
|
||||
.then(function () {
|
||||
return image.encodedWith.oxipng;
|
||||
})
|
||||
.then(function () {
|
||||
deferred.resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
// mapnik
|
||||
mapnik && pngSuite.add('mapnik-file-file', {
|
||||
defer: true,
|
||||
@ -691,13 +745,13 @@ async.series({
|
||||
if (err) throw err;
|
||||
img.premultiply(function (err, img) {
|
||||
if (err) throw err;
|
||||
img.resize(width, height, {
|
||||
img.resize(width, heightPng, {
|
||||
scaling_method: mapnik.imageScaling.lanczos
|
||||
}, function (err, img) {
|
||||
if (err) throw err;
|
||||
img.demultiply(function (err, img) {
|
||||
if (err) throw err;
|
||||
img.save(outputPng, 'png', function (err) {
|
||||
img.save(outputPng, 'png32:f=no:z=6', function (err) {
|
||||
if (err) throw err;
|
||||
deferred.resolve();
|
||||
});
|
||||
@ -713,13 +767,13 @@ async.series({
|
||||
if (err) throw err;
|
||||
img.premultiply(function (err, img) {
|
||||
if (err) throw err;
|
||||
img.resize(width, height, {
|
||||
img.resize(width, heightPng, {
|
||||
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) {
|
||||
img.encode('png32:f=no:z=6', function (err) {
|
||||
if (err) throw err;
|
||||
deferred.resolve();
|
||||
});
|
||||
@ -737,7 +791,7 @@ async.series({
|
||||
srcPath: fixtures.inputPngAlphaPremultiplicationLarge,
|
||||
dstPath: outputPng,
|
||||
width: width,
|
||||
height: height,
|
||||
height: heightPng,
|
||||
filter: 'Lanczos',
|
||||
customArgs: [
|
||||
'-define', 'PNG:compression-level=6',
|
||||
@ -758,7 +812,7 @@ async.series({
|
||||
fn: function (deferred) {
|
||||
gm(fixtures.inputPngAlphaPremultiplicationLarge)
|
||||
.filter('Lanczos')
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.define('PNG:compression-level=6')
|
||||
.define('PNG:compression-filter=0')
|
||||
.write(outputPng, function (err) {
|
||||
@ -774,7 +828,7 @@ async.series({
|
||||
fn: function (deferred) {
|
||||
gm(fixtures.inputPngAlphaPremultiplicationLarge)
|
||||
.filter('Lanczos')
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.define('PNG:compression-level=6')
|
||||
.define('PNG:compression-filter=0')
|
||||
.toBuffer(function (err) {
|
||||
@ -792,7 +846,7 @@ async.series({
|
||||
minSamples,
|
||||
fn: function (deferred) {
|
||||
sharp(inputPngBuffer)
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.png({ compressionLevel: 6 })
|
||||
.toFile(outputPng, function (err) {
|
||||
if (err) {
|
||||
@ -807,9 +861,9 @@ async.series({
|
||||
minSamples,
|
||||
fn: function (deferred) {
|
||||
sharp(inputPngBuffer)
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.png({ compressionLevel: 6 })
|
||||
.toBuffer(function (err) {
|
||||
.toBuffer(function (err, data) {
|
||||
if (err) {
|
||||
throw err;
|
||||
} else {
|
||||
@ -822,7 +876,7 @@ async.series({
|
||||
minSamples,
|
||||
fn: function (deferred) {
|
||||
sharp(fixtures.inputPngAlphaPremultiplicationLarge)
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.png({ compressionLevel: 6 })
|
||||
.toFile(outputPng, function (err) {
|
||||
if (err) {
|
||||
@ -837,7 +891,7 @@ async.series({
|
||||
minSamples,
|
||||
fn: function (deferred) {
|
||||
sharp(fixtures.inputPngAlphaPremultiplicationLarge)
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.png({ compressionLevel: 6 })
|
||||
.toBuffer(function (err) {
|
||||
if (err) {
|
||||
@ -852,7 +906,7 @@ async.series({
|
||||
minSamples,
|
||||
fn: function (deferred) {
|
||||
sharp(inputPngBuffer)
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.png({ compressionLevel: 6, progressive: true })
|
||||
.toBuffer(function (err) {
|
||||
if (err) {
|
||||
@ -867,7 +921,7 @@ async.series({
|
||||
minSamples,
|
||||
fn: function (deferred) {
|
||||
sharp(inputPngBuffer)
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.png({ adaptiveFiltering: true, compressionLevel: 6 })
|
||||
.toBuffer(function (err) {
|
||||
if (err) {
|
||||
@ -882,7 +936,7 @@ async.series({
|
||||
minSamples,
|
||||
fn: function (deferred) {
|
||||
sharp(inputPngBuffer)
|
||||
.resize(width, height)
|
||||
.resize(width, heightPng)
|
||||
.png({ compressionLevel: 9 })
|
||||
.toBuffer(function (err) {
|
||||
if (err) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user