mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Ensure animation-related properties work with stream-based input
This commit is contained in:
parent
76dcddfa3d
commit
08a2965f1c
@ -9,9 +9,9 @@ const sharp = require('../build/Release/sharp.node');
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function _inputOptionsFromObject (obj) {
|
function _inputOptionsFromObject (obj) {
|
||||||
const { raw, density, limitInputPixels, sequentialRead, failOnError } = obj;
|
const { raw, density, limitInputPixels, sequentialRead, failOnError, animated, page, pages } = obj;
|
||||||
return [raw, density, limitInputPixels, sequentialRead, failOnError].some(is.defined)
|
return [raw, density, limitInputPixels, sequentialRead, failOnError, animated, page, pages].some(is.defined)
|
||||||
? { raw, density, limitInputPixels, sequentialRead, failOnError }
|
? { raw, density, limitInputPixels, sequentialRead, failOnError, animated, page, pages }
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,4 +98,36 @@ describe('GIF input', () => {
|
|||||||
sharp().gif({ delay: [65536] });
|
sharp().gif({ delay: [65536] });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should work with streams when only animated is set', function (done) {
|
||||||
|
if (sharp.format.magick.output.buffer) {
|
||||||
|
fs.createReadStream(fixtures.inputGifAnimated)
|
||||||
|
.pipe(sharp({ animated: true }))
|
||||||
|
.gif()
|
||||||
|
.toBuffer(function (err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(true, data.length > 0);
|
||||||
|
assert.strictEqual('gif', info.format);
|
||||||
|
fixtures.assertSimilar(fixtures.inputGifAnimated, data, done);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should work with streams when only pages is set', function (done) {
|
||||||
|
if (sharp.format.magick.output.buffer) {
|
||||||
|
fs.createReadStream(fixtures.inputGifAnimated)
|
||||||
|
.pipe(sharp({ pages: -1 }))
|
||||||
|
.gif()
|
||||||
|
.toBuffer(function (err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(true, data.length > 0);
|
||||||
|
assert.strictEqual('gif', info.format);
|
||||||
|
fixtures.assertSimilar(fixtures.inputGifAnimated, data, done);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const sharp = require('../../');
|
const sharp = require('../../');
|
||||||
@ -184,4 +185,28 @@ describe('WebP', function () {
|
|||||||
|
|
||||||
assert.deepStrictEqual(updated.delay, expectedDelay);
|
assert.deepStrictEqual(updated.delay, expectedDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should work with streams when only animated is set', function (done) {
|
||||||
|
fs.createReadStream(fixtures.inputWebPAnimated)
|
||||||
|
.pipe(sharp({ animated: true }))
|
||||||
|
.webp({ lossless: true })
|
||||||
|
.toBuffer(function (err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(true, data.length > 0);
|
||||||
|
assert.strictEqual('webp', info.format);
|
||||||
|
fixtures.assertSimilar(fixtures.inputWebPAnimated, data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should work with streams when only pages is set', function (done) {
|
||||||
|
fs.createReadStream(fixtures.inputWebPAnimated)
|
||||||
|
.pipe(sharp({ pages: -1 }))
|
||||||
|
.webp({ lossless: true })
|
||||||
|
.toBuffer(function (err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(true, data.length > 0);
|
||||||
|
assert.strictEqual('webp', info.format);
|
||||||
|
fixtures.assertSimilar(fixtures.inputWebPAnimated, data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user