Skip to content

Commit

Permalink
fix: enable tolerantDecoding by default
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Apr 23, 2020
1 parent 135705b commit 5d3277f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,8 @@ var JpegImage = (function jpegImage() {
// The adobe transform marker overrides any previous setting
if (this.adobe && this.adobe.transformCode)
colorTransform = true;
else if (typeof this.colorTransform !== 'undefined')
colorTransform = !!this.colorTransform;
else if (typeof this.opts.colorTransform !== 'undefined')
colorTransform = !!this.opts.colorTransform;

component1 = this.components[0];
component2 = this.components[1];
Expand Down Expand Up @@ -925,8 +925,8 @@ var JpegImage = (function jpegImage() {
// The adobe transform marker overrides any previous setting
if (this.adobe && this.adobe.transformCode)
colorTransform = true;
else if (typeof this.colorTransform !== 'undefined')
colorTransform = !!this.colorTransform;
else if (typeof this.opts.colorTransform !== 'undefined')
colorTransform = !!this.opts.colorTransform;

component1 = this.components[0];
component2 = this.components[1];
Expand Down Expand Up @@ -1066,11 +1066,11 @@ if (typeof module !== 'undefined') {

function decode(jpegData, userOpts = {}) {
var defaultOpts = {
useTArray: false,
// "undefined" means "Choose whether to transform colors based on the image’s color model."
colorTransform: undefined,
useTArray: false,
formatAsRGBA: true,
tolerantDecoding: false,
tolerantDecoding: true,
maxResolutionInMP: 100, // Don't decode more than 100 megapixels
maxMemoryUsageInMB: 512, // Don't decode if memory footprint is more than 512MB
};
Expand All @@ -1083,7 +1083,6 @@ function decode(jpegData, userOpts = {}) {
// Until then, treating as singleton limit is fine.
JpegImage.resetMaxMemoryUsage(opts.maxMemoryUsageInMB * 1024 * 1024);
decoder.parse(arr);
decoder.colorTransform = opts.colorTransform;

var channels = (opts.formatAsRGBA) ? 4 : 3;
var bytesNeeded = decoder.width * decoder.height * channels;
Expand Down

0 comments on commit 5d3277f

Please sign in to comment.