mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 02:30:12 +02:00
parent
6b34e8a804
commit
e0d622d347
@ -220,12 +220,12 @@ class PipelineWorker : public Nan::AsyncWorker {
|
||||
}
|
||||
|
||||
// If integral x and y shrink are equal, try to use shrink-on-load for JPEG and WebP,
|
||||
// but not when applying gamma correction or pre-resize extract
|
||||
// but not when applying gamma correction, pre-resize extract or trim
|
||||
int shrink_on_load = 1;
|
||||
if (
|
||||
xshrink == yshrink && xshrink >= 2 &&
|
||||
(inputImageType == ImageType::JPEG || inputImageType == ImageType::WEBP) &&
|
||||
baton->gamma == 0 && baton->topOffsetPre == -1
|
||||
baton->gamma == 0 && baton->topOffsetPre == -1 && baton->trimTolerance == 0
|
||||
) {
|
||||
if (xshrink >= 8) {
|
||||
xfactor = xfactor / 8;
|
||||
|
BIN
test/fixtures/alpha-layer-2-ink.jpg
vendored
Normal file
BIN
test/fixtures/alpha-layer-2-ink.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
test/fixtures/expected/alpha-layer-2-trim-resize.jpg
vendored
Normal file
BIN
test/fixtures/expected/alpha-layer-2-trim-resize.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
1
test/fixtures/index.js
vendored
1
test/fixtures/index.js
vendored
@ -65,6 +65,7 @@ module.exports = {
|
||||
inputJpgWithLowContrast: getPath('low-contrast.jpg'), // http://www.flickr.com/photos/grizdave/2569067123/
|
||||
inputJpgLarge: getPath('giant-image.jpg'),
|
||||
inputJpg320x240: getPath('320x240.jpg'), // http://www.andrewault.net/2010/01/26/create-a-test-pattern-video-with-perl/
|
||||
inputJpgOverlayLayer2: getPath('alpha-layer-2-ink.jpg'),
|
||||
|
||||
inputPng: getPath('50020484-00001.png'), // http://c.searspartsdirect.com/lis_png/PLDM/50020484-00001.png
|
||||
inputPngWithTransparency: getPath('blackbug.png'), // public domain
|
||||
|
@ -20,6 +20,20 @@ describe('Trim borders', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Skip shrink-on-load', function (done) {
|
||||
const expected = fixtures.expected('alpha-layer-2-trim-resize.jpg');
|
||||
sharp(fixtures.inputJpgOverlayLayer2)
|
||||
.trim()
|
||||
.resize(300)
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(300, info.width);
|
||||
assert.strictEqual(300, info.height);
|
||||
fixtures.assertSimilar(expected, data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('16-bit PNG with alpha channel', function (done) {
|
||||
sharp(fixtures.inputPngWithTransparency16bit)
|
||||
.resize(32, 32)
|
||||
|
Loading…
x
Reference in New Issue
Block a user