mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Expose mozjpeg quant_table flag (#1285)
This commit is contained in:
committed by
Lovell Fuller
parent
5cb35485f1
commit
7bbc5176a1
@@ -389,6 +389,16 @@ describe('Input/output', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Invalid JPEG quantisation table', function () {
|
||||
[-1, 88.2, 'test'].forEach(function (table) {
|
||||
it(table.toString(), function () {
|
||||
assert.throws(function () {
|
||||
sharp().jpeg({ quantisationTable: table });
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Progressive JPEG image', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
@@ -856,6 +866,37 @@ describe('Input/output', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Specifying quantisation table provides different JPEG', function (done) {
|
||||
// First generate with default quantisation table
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.jpeg({ optimiseCoding: false })
|
||||
.toBuffer(function (err, withDefaultQuantisationTable, withInfo) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, withDefaultQuantisationTable.length > 0);
|
||||
assert.strictEqual(withDefaultQuantisationTable.length, withInfo.size);
|
||||
assert.strictEqual('jpeg', withInfo.format);
|
||||
assert.strictEqual(320, withInfo.width);
|
||||
assert.strictEqual(240, withInfo.height);
|
||||
// Then generate with different quantisation table
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.jpeg({ optimiseCoding: false, quantisationTable: 3 })
|
||||
.toBuffer(function (err, withQuantTable3, withoutInfo) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, withQuantTable3.length > 0);
|
||||
assert.strictEqual(withQuantTable3.length, withoutInfo.size);
|
||||
assert.strictEqual('jpeg', withoutInfo.format);
|
||||
assert.strictEqual(320, withoutInfo.width);
|
||||
assert.strictEqual(240, withoutInfo.height);
|
||||
|
||||
// Verify image is same (as mozjpeg may not be present) size or less
|
||||
assert.strictEqual(true, withQuantTable3.length <= withDefaultQuantisationTable.length);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Convert SVG to PNG at default 72DPI', function (done) {
|
||||
sharp(fixtures.inputSvg)
|
||||
.resize(1024)
|
||||
|
||||
Reference in New Issue
Block a user