mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Improve multi-frame image resizing (#2789)
* Ports vips_thumbnail logic to sharp * Deprecates the pageHeight output option for WebP/GIF
This commit is contained in:
committed by
GitHub
parent
659cdabd8e
commit
513fb40f40
@@ -39,10 +39,35 @@ describe('Partial image extraction', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Animated WebP', function () {
|
||||
it('Before resize', function (done) {
|
||||
sharp(fixtures.inputWebPAnimated, { pages: -1 })
|
||||
.extract({ left: 0, top: 30, width: 80, height: 20 })
|
||||
.resize(320, 80)
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(80 * 9, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('gravity-center-height.webp'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('After resize', function (done) {
|
||||
sharp(fixtures.inputWebPAnimated, { pages: -1 })
|
||||
.resize(320, 320)
|
||||
.extract({ left: 0, top: 120, width: 320, height: 80 })
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(80 * 9, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('gravity-center-height.webp'), data, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('TIFF', function (done) {
|
||||
sharp(fixtures.inputTiff)
|
||||
.extract({ left: 34, top: 63, width: 341, height: 529 })
|
||||
.jpeg()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(341, info.width);
|
||||
|
||||
Reference in New Issue
Block a user