mirror of
https://github.com/lovell/sharp.git
synced 2025-07-10 11:00:14 +02:00
Skip shrink-on-load where one dimension <4px #2653
This commit is contained in:
parent
d1ca756bd8
commit
ed5d753b89
@ -4,6 +4,11 @@
|
|||||||
|
|
||||||
Requires libvips v8.10.6
|
Requires libvips v8.10.6
|
||||||
|
|
||||||
|
### v0.28.2 - TBD
|
||||||
|
|
||||||
|
* Skip shrink-on-load where one dimension <4px.
|
||||||
|
[#2653](https://github.com/lovell/sharp/issues/2653)
|
||||||
|
|
||||||
### v0.28.1 - 5th April 2021
|
### v0.28.1 - 5th April 2021
|
||||||
|
|
||||||
* Ensure all installation errors are logged with a more obvious prefix.
|
* Ensure all installation errors are logged with a more obvious prefix.
|
||||||
|
@ -226,7 +226,8 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
if (
|
if (
|
||||||
xshrink == yshrink && xshrink >= 2 * shrink_on_load_factor &&
|
xshrink == yshrink && xshrink >= 2 * shrink_on_load_factor &&
|
||||||
(inputImageType == sharp::ImageType::JPEG || inputImageType == sharp::ImageType::WEBP) &&
|
(inputImageType == sharp::ImageType::JPEG || inputImageType == sharp::ImageType::WEBP) &&
|
||||||
baton->gamma == 0 && baton->topOffsetPre == -1 && baton->trimThreshold == 0.0
|
baton->gamma == 0 && baton->topOffsetPre == -1 && baton->trimThreshold == 0.0 &&
|
||||||
|
image.width() > 3 && image.height() > 3
|
||||||
) {
|
) {
|
||||||
if (xshrink >= 8 * shrink_on_load_factor) {
|
if (xshrink >= 8 * shrink_on_load_factor) {
|
||||||
xfactor = xfactor / 8;
|
xfactor = xfactor / 8;
|
||||||
|
@ -605,6 +605,26 @@ describe('Resize dimensions', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Skip shrink-on-load where one dimension <4px', async () => {
|
||||||
|
const jpeg = await sharp({
|
||||||
|
create: {
|
||||||
|
width: 100,
|
||||||
|
height: 3,
|
||||||
|
channels: 3,
|
||||||
|
background: 'red'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.jpeg()
|
||||||
|
.toBuffer();
|
||||||
|
|
||||||
|
const { info } = await sharp(jpeg)
|
||||||
|
.resize(8)
|
||||||
|
.toBuffer({ resolveWithObject: true });
|
||||||
|
|
||||||
|
assert.strictEqual(info.width, 8);
|
||||||
|
assert.strictEqual(info.height, 1);
|
||||||
|
});
|
||||||
|
|
||||||
it('unknown kernel throws', function () {
|
it('unknown kernel throws', function () {
|
||||||
assert.throws(function () {
|
assert.throws(function () {
|
||||||
sharp().resize(null, null, { kernel: 'unknown' });
|
sharp().resize(null, null, { kernel: 'unknown' });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user