Donaldcwl / browser-image-compression

Image compression in web browser
MIT License
1.31k stars 161 forks source link

[feature request] keep the same width and height, and reduce the quality only #127

Closed GeekaholicLin closed 2 years ago

GeekaholicLin commented 3 years ago

Thanks for the awesome library for the image compression!

I noticed that the width/height of the image will be reduced to meet the maxSizeMB.

Is it possible to provide the option to keep the same width and height of the original image file and reduce the quality only?

https://github.com/Donaldcwl/browser-image-compression/blob/master/lib/image-compression.js#L95-L96

Donaldcwl commented 2 years ago

v2.0.0 added options.alwaysKeepResolution, for example:

const options = {
    maxSizeMB: 1,
    useWebWorker: true,
    alwaysKeepResolution: true,
  }
  const compressedFile = await imageCompression(imageFile, options);