mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Allow images with alpha channel to use LAB sharpen #490
This commit is contained in:
parent
b70a7d9a3b
commit
4c172d25f6
@ -38,6 +38,10 @@ Requires libvips v8.3.1
|
|||||||
[#486](https://github.com/lovell/sharp/issues/486)
|
[#486](https://github.com/lovell/sharp/issues/486)
|
||||||
[@kapouer](https://github.com/kapouer)
|
[@kapouer](https://github.com/kapouer)
|
||||||
|
|
||||||
|
* Allow images with an alpha channel to work with LAB-colourspace based sharpen.
|
||||||
|
[#490](https://github.com/lovell/sharp/issues/490)
|
||||||
|
[@jwagner](https://github.com/jwagner)
|
||||||
|
|
||||||
#### v0.15.0 - 21<sup>st</sup> May 2016
|
#### v0.15.0 - 21<sup>st</sup> May 2016
|
||||||
|
|
||||||
* Use libvips' new Lanczos 3 kernel as default for image reduction.
|
* Use libvips' new Lanczos 3 kernel as default for image reduction.
|
||||||
|
@ -244,9 +244,13 @@ namespace sharp {
|
|||||||
return image.conv(sharpen);
|
return image.conv(sharpen);
|
||||||
} else {
|
} else {
|
||||||
// Slow, accurate sharpen in LAB colour space, with control over flat vs jagged areas
|
// Slow, accurate sharpen in LAB colour space, with control over flat vs jagged areas
|
||||||
|
VipsInterpretation colourspaceBeforeSharpen = image.interpretation();
|
||||||
|
if (colourspaceBeforeSharpen == VIPS_INTERPRETATION_RGB) {
|
||||||
|
colourspaceBeforeSharpen = VIPS_INTERPRETATION_sRGB;
|
||||||
|
}
|
||||||
return image.sharpen(
|
return image.sharpen(
|
||||||
VImage::option()->set("sigma", sigma)->set("m1", flat)->set("m2", jagged)
|
VImage::option()->set("sigma", sigma)->set("m1", flat)->set("m2", jagged)
|
||||||
);
|
).colourspace(colourspaceBeforeSharpen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
test/fixtures/expected/sharpen-rgba.png
vendored
Normal file
BIN
test/fixtures/expected/sharpen-rgba.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
@ -12,6 +12,7 @@ describe('Sharpen', function() {
|
|||||||
.resize(320, 240)
|
.resize(320, 240)
|
||||||
.sharpen(6)
|
.sharpen(6)
|
||||||
.toBuffer(function(err, data, info) {
|
.toBuffer(function(err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
assert.strictEqual(320, info.width);
|
assert.strictEqual(320, info.width);
|
||||||
assert.strictEqual(240, info.height);
|
assert.strictEqual(240, info.height);
|
||||||
@ -24,6 +25,7 @@ describe('Sharpen', function() {
|
|||||||
.resize(320, 240)
|
.resize(320, 240)
|
||||||
.sharpen(1.5, 0.5, 2.5)
|
.sharpen(1.5, 0.5, 2.5)
|
||||||
.toBuffer(function(err, data, info) {
|
.toBuffer(function(err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
assert.strictEqual(320, info.width);
|
assert.strictEqual(320, info.width);
|
||||||
assert.strictEqual(240, info.height);
|
assert.strictEqual(240, info.height);
|
||||||
@ -36,6 +38,7 @@ describe('Sharpen', function() {
|
|||||||
.resize(320, 240)
|
.resize(320, 240)
|
||||||
.sharpen(3.5, 2, 4)
|
.sharpen(3.5, 2, 4)
|
||||||
.toBuffer(function(err, data, info) {
|
.toBuffer(function(err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
assert.strictEqual(320, info.width);
|
assert.strictEqual(320, info.width);
|
||||||
assert.strictEqual(240, info.height);
|
assert.strictEqual(240, info.height);
|
||||||
@ -43,11 +46,26 @@ describe('Sharpen', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('specific radius/levels with alpha channel', function(done) {
|
||||||
|
sharp(fixtures.inputPngWithTransparency)
|
||||||
|
.resize(320, 240)
|
||||||
|
.sharpen(5, 4, 8)
|
||||||
|
.toBuffer(function(err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual('png', info.format);
|
||||||
|
assert.strictEqual(4, info.channels);
|
||||||
|
assert.strictEqual(320, info.width);
|
||||||
|
assert.strictEqual(240, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('sharpen-rgba.png'), data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('mild sharpen', function(done) {
|
it('mild sharpen', function(done) {
|
||||||
sharp(fixtures.inputJpg)
|
sharp(fixtures.inputJpg)
|
||||||
.resize(320, 240)
|
.resize(320, 240)
|
||||||
.sharpen()
|
.sharpen()
|
||||||
.toBuffer(function(err, data, info) {
|
.toBuffer(function(err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
assert.strictEqual(320, info.width);
|
assert.strictEqual(320, info.width);
|
||||||
assert.strictEqual(240, info.height);
|
assert.strictEqual(240, info.height);
|
||||||
@ -78,6 +96,7 @@ describe('Sharpen', function() {
|
|||||||
.resize(320, 240)
|
.resize(320, 240)
|
||||||
.sharpen(false)
|
.sharpen(false)
|
||||||
.toBuffer(function(err, notSharpened, info) {
|
.toBuffer(function(err, notSharpened, info) {
|
||||||
|
if (err) throw err;
|
||||||
assert.strictEqual(true, notSharpened.length > 0);
|
assert.strictEqual(true, notSharpened.length > 0);
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
assert.strictEqual(320, info.width);
|
assert.strictEqual(320, info.width);
|
||||||
@ -86,6 +105,7 @@ describe('Sharpen', function() {
|
|||||||
.resize(320, 240)
|
.resize(320, 240)
|
||||||
.sharpen(true)
|
.sharpen(true)
|
||||||
.toBuffer(function(err, sharpened, info) {
|
.toBuffer(function(err, sharpened, info) {
|
||||||
|
if (err) throw err;
|
||||||
assert.strictEqual(true, sharpened.length > 0);
|
assert.strictEqual(true, sharpened.length > 0);
|
||||||
assert.strictEqual(true, sharpened.length > notSharpened.length);
|
assert.strictEqual(true, sharpened.length > notSharpened.length);
|
||||||
assert.strictEqual('jpeg', info.format);
|
assert.strictEqual('jpeg', info.format);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user