mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Gamma correction and premultiply do not mix
Skip premultiply for fast blur/sharpen Automate gamma correction tests
This commit is contained in:
@@ -12,32 +12,53 @@ describe('Gamma correction', function() {
|
||||
it('value of 0.0 (disabled)', function(done) {
|
||||
sharp(fixtures.inputJpgWithGammaHoliness)
|
||||
.resize(129, 111)
|
||||
.toFile(fixtures.path('output.gamma-0.0.jpg'), done);
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(129, info.width);
|
||||
assert.strictEqual(111, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('gamma-0.0.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('value of 2.2 (default)', function(done) {
|
||||
sharp(fixtures.inputJpgWithGammaHoliness)
|
||||
.resize(129, 111)
|
||||
.gamma()
|
||||
.toFile(fixtures.path('output.gamma-2.2.jpg'), done);
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(129, info.width);
|
||||
assert.strictEqual(111, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('gamma-2.2.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('value of 3.0', function(done) {
|
||||
sharp(fixtures.inputJpgWithGammaHoliness)
|
||||
.resize(129, 111)
|
||||
.gamma(3)
|
||||
.toFile(fixtures.path('output.gamma-3.0.jpg'), done);
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(129, info.width);
|
||||
assert.strictEqual(111, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('gamma-3.0.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('invalid value', function(done) {
|
||||
var isValid = true;
|
||||
try {
|
||||
it('alpha transparency', function(done) {
|
||||
sharp(fixtures.inputPngOverlayLayer1)
|
||||
.resize(320)
|
||||
.gamma()
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
fixtures.assertSimilar(fixtures.expected('gamma-alpha.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('invalid value', function() {
|
||||
assert.throws(function() {
|
||||
sharp(fixtures.inputJpgWithGammaHoliness).gamma(4);
|
||||
} catch (err) {
|
||||
isValid = false;
|
||||
}
|
||||
assert.strictEqual(false, isValid);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user