Donaldcwl / browser-image-compression

Image compression in web browser
MIT License
1.3k stars 160 forks source link

Feature Request: controllable "quality" field #78

Closed ndanvers closed 4 years ago

ndanvers commented 4 years ago

Hello there and thank you for this wonderful package.

Current Behavior: Within image-compression.js, the quality is set via: let quality = 1

It is further affected in the case of a jpeg:

if (file.type === 'image/jpeg') {
      quality *= 0.95
    }

Desired Behavior Ability to input a quality field in the options passed to browser-image-compressor, like so:

let options = {
        maxSizeMB: 2,
        maxWidthOrHeight: 2048, 
        quality: 0.5
}

reasoning I believe that there are certain use cases where it would be extremely useful to have more control over this.

Thank you again

Donaldcwl commented 4 years ago

Added initialQuality options in v1.0.13 e.g.:

const options = {
        maxSizeMB: 2,
        maxWidthOrHeight: 2048, 
        initialQuality: 0.5
}

Thank you

ndanvers commented 4 years ago

Fantastic, thank you for this addition.