Add test for progressive JPEG output

This commit is contained in:
Lovell Fuller 2015-03-30 11:36:14 +01:00
parent bd96a49de6
commit 7ad7193b1e

View File

@ -263,7 +263,34 @@ describe('Input/output', function() {
done(); done();
}); });
it('Progressive image', function(done) { it('Progressive JPEG image', function(done) {
sharp(fixtures.inputJpg)
.resize(320, 240)
.progressive(false)
.toBuffer(function(err, nonProgressiveData, nonProgressiveInfo) {
if (err) throw err;
assert.strictEqual(true, nonProgressiveData.length > 0);
assert.strictEqual(nonProgressiveData.length, nonProgressiveInfo.size);
assert.strictEqual('jpeg', nonProgressiveInfo.format);
assert.strictEqual(320, nonProgressiveInfo.width);
assert.strictEqual(240, nonProgressiveInfo.height);
sharp(fixtures.inputJpg)
.resize(320, 240)
.progressive()
.toBuffer(function(err, progressiveData, progressiveInfo) {
if (err) throw err;
assert.strictEqual(true, progressiveData.length > 0);
assert.strictEqual(progressiveData.length, progressiveInfo.size);
assert.strictEqual(false, progressiveData.length === nonProgressiveData.length);
assert.strictEqual('jpeg', progressiveInfo.format);
assert.strictEqual(320, progressiveInfo.width);
assert.strictEqual(240, progressiveInfo.height);
done();
});
});
});
it('Progressive PNG image', function(done) {
sharp(fixtures.inputJpg) sharp(fixtures.inputJpg)
.resize(320, 240) .resize(320, 240)
.png() .png()