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
@@ -150,6 +150,8 @@ function withMetadata (withMetadata) {
|
||||
* @param {Boolean} [options.optimizeScans=false] - alternative spelling of optimiseScans
|
||||
* @param {Boolean} [options.optimiseCoding=true] - optimise Huffman coding tables
|
||||
* @param {Boolean} [options.optimizeCoding=true] - alternative spelling of optimiseCoding
|
||||
* @param {Number} [options.quantisationTable=0] - quantization table to use, integer 0-8, requires mozjpeg
|
||||
* @param {Number} [options.quantizationTable=0] - alternative spelling of quantisationTable
|
||||
* @param {Boolean} [options.force=true] - force JPEG output, otherwise attempt to use input format
|
||||
* @returns {Sharp}
|
||||
* @throws {Error} Invalid options
|
||||
@@ -191,6 +193,14 @@ function jpeg (options) {
|
||||
if (is.defined(options.optimiseCoding)) {
|
||||
this._setBooleanOption('jpegOptimiseCoding', options.optimiseCoding);
|
||||
}
|
||||
options.quantisationTable = is.number(options.quantizationTable) ? options.quantizationTable : options.quantisationTable;
|
||||
if (is.defined(options.quantisationTable)) {
|
||||
if (is.integer(options.quantisationTable) && is.inRange(options.quantisationTable, 0, 8)) {
|
||||
this.options.jpegQuantisationTable = options.quantisationTable;
|
||||
} else {
|
||||
throw new Error('Invalid quantisation table (integer, 0-8) ' + options.quantisationTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this._updateFormatOut('jpeg', options);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user