mirror of
https://github.com/lovell/sharp.git
synced 2025-07-10 19:10:14 +02:00
Prevent aliasing by using dynamic values for shrink(-on-load)
This commit is contained in:
parent
48f69f3d88
commit
e398b471e1
@ -41,6 +41,10 @@ Requires libvips v8.5.2.
|
|||||||
[#772](https://github.com/lovell/sharp/issues/772)
|
[#772](https://github.com/lovell/sharp/issues/772)
|
||||||
[@ajiratech2](https://github.com/ajiratech2)
|
[@ajiratech2](https://github.com/ajiratech2)
|
||||||
|
|
||||||
|
* Prevent aliasing by using dynamic values for shrink(-on-load).
|
||||||
|
[#781](https://github.com/lovell/sharp/issues/781)
|
||||||
|
[@kleisauke](https://github.com/kleisauke)
|
||||||
|
|
||||||
* Expose libvips' "squash" parameter to enable 1-bit TIFF output.
|
* Expose libvips' "squash" parameter to enable 1-bit TIFF output.
|
||||||
[#783](https://github.com/lovell/sharp/pull/783)
|
[#783](https://github.com/lovell/sharp/pull/783)
|
||||||
[@YvesBos](https://github.com/YvesBos)
|
[@YvesBos](https://github.com/YvesBos)
|
||||||
|
@ -242,6 +242,12 @@ class PipelineWorker : public Nan::AsyncWorker {
|
|||||||
shrink_on_load = 2;
|
shrink_on_load = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Help ensure a final kernel-based reduction to prevent shrink aliasing
|
||||||
|
if (shrink_on_load > 1 && (xresidual == 1.0 || yresidual == 1.0)) {
|
||||||
|
shrink_on_load = shrink_on_load / 2;
|
||||||
|
xfactor = xfactor * 2;
|
||||||
|
yfactor = yfactor * 2;
|
||||||
|
}
|
||||||
if (shrink_on_load > 1) {
|
if (shrink_on_load > 1) {
|
||||||
// Reload input using shrink-on-load
|
// Reload input using shrink-on-load
|
||||||
vips::VOption *option = VImage::option()->set("shrink", shrink_on_load);
|
vips::VOption *option = VImage::option()->set("shrink", shrink_on_load);
|
||||||
@ -285,6 +291,13 @@ class PipelineWorker : public Nan::AsyncWorker {
|
|||||||
std::swap(xresidual, yresidual);
|
std::swap(xresidual, yresidual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Help ensure a final kernel-based reduction to prevent shrink aliasing
|
||||||
|
if ((xshrink > 1 || yshrink > 1) && (xresidual == 1.0 || yresidual == 1.0)) {
|
||||||
|
xshrink = xshrink / 2;
|
||||||
|
yshrink = yshrink / 2;
|
||||||
|
xresidual = xresidual / 2.0;
|
||||||
|
yresidual = yresidual / 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure we're using a device-independent colour space
|
// Ensure we're using a device-independent colour space
|
||||||
if (sharp::HasProfile(image)) {
|
if (sharp::HasProfile(image)) {
|
||||||
|
BIN
test/fixtures/expected/embed-16bit-rgba.png
vendored
BIN
test/fixtures/expected/embed-16bit-rgba.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 987 B |
BIN
test/fixtures/expected/extend-2channel.png
vendored
BIN
test/fixtures/expected/extend-2channel.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
BIN
test/fixtures/expected/gamma-0.0.jpg
vendored
BIN
test/fixtures/expected/gamma-0.0.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 359 B After Width: | Height: | Size: 614 B |
@ -1335,7 +1335,7 @@ describe('Input/output', function () {
|
|||||||
assert.strictEqual(256, info.width);
|
assert.strictEqual(256, info.width);
|
||||||
assert.strictEqual(192, info.height);
|
assert.strictEqual(192, info.height);
|
||||||
assert.strictEqual(4, info.channels);
|
assert.strictEqual(4, info.channels);
|
||||||
fixtures.assertSimilar(fixtures.inputPngOverlayLayer1, data, done);
|
fixtures.assertSimilar(fixtures.inputPngOverlayLayer1, data, { threshold: 7 }, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user