Skip to content

Stop returning original file when the optimization is larger than the original file#285

Merged
sindresorhus merged 3 commits intoimagemin:masterfrom
malash:remove-length-optimization
Dec 25, 2018
Merged

Stop returning original file when the optimization is larger than the original file#285
sindresorhus merged 3 commits intoimagemin:masterfrom
malash:remove-length-optimization

Conversation

@malash
Copy link
Copy Markdown
Contributor

@malash malash commented Jul 16, 2018

Some plugins, like imagemin-svgo's addAttributesToSVGElement plugin, may increase image size.

So here

buf = buf.length < data.length ? buf : data;

and

return pPipe(opts.plugins)(input).then(buf => (buf.length < input.length ? buf : input));

may cause plugins to fail.

I advice to disable the optimization based on length.

I think it should be users' duty and right to detect which plugin is effective and which one should be abandoned but imagemin shouldn't do that work.

@sindresorhus sindresorhus changed the title Disable optimization based on length Stop returning original file when the optimization is larger than the original file Dec 25, 2018
@sindresorhus sindresorhus merged commit 744a6c2 into imagemin:master Dec 25, 2018
@XhmikosR
Copy link
Copy Markdown

Maybe we should add an option --force in imagemin-jpegoptim which by default is false and thus do what jpegoptim does right now?

@XhmikosR
Copy link
Copy Markdown

But then this needs to be done for all plugins that support such option whereas here it was in one place.

@malash malash deleted the remove-length-optimization branch May 5, 2019 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants