Expose libjpeg optimize_coding flag (#1265)

This commit is contained in:
Tom Lokhorst
2018-06-21 19:12:10 +02:00
committed by Lovell Fuller
parent 873aa6700f
commit 76c41eaf05
5 changed files with 43 additions and 3 deletions

View File

@@ -192,6 +192,7 @@ const Sharp = function (input, options) {
jpegTrellisQuantisation: false,
jpegOvershootDeringing: false,
jpegOptimiseScans: false,
jpegOptimiseCoding: true,
pngProgressive: false,
pngCompressionLevel: 9,
pngAdaptiveFiltering: false,

View File

@@ -148,6 +148,8 @@ function withMetadata (withMetadata) {
* @param {Boolean} [options.overshootDeringing=false] - apply overshoot deringing, requires mozjpeg
* @param {Boolean} [options.optimiseScans=false] - optimise progressive scans, forces progressive, requires mozjpeg
* @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 {Boolean} [options.force=true] - force JPEG output, otherwise attempt to use input format
* @returns {Sharp}
* @throws {Error} Invalid options
@@ -185,6 +187,10 @@ function jpeg (options) {
this.options.jpegProgressive = true;
}
}
options.optimiseCoding = is.bool(options.optimizeCoding) ? options.optimizeCoding : options.optimiseCoding;
if (is.defined(options.optimiseCoding)) {
this._setBooleanOption('jpegOptimiseCoding', options.optimiseCoding);
}
}
return this._updateFormatOut('jpeg', options);
}