Donaldcwl / browser-image-compression

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

PNG Not compressing to the max Size specified #176

Open mdayeen opened 1 year ago

mdayeen commented 1 year ago

PNG files are not being compress to size specified.

Donaldcwl commented 1 year ago

@mdayeen Can you provide the config you use and the image as a zip file?

imtiazShakil commented 6 months ago

I face the same issue, png file compression doesn't respect maxSizeMB limit. here is my configuration:

{
          maxSizeMB: 0.5,
          maxWidthOrHeight: 1200,
          alwaysKeepResolution: true,
}
imtiazShakil commented 6 months ago

if I increase the maxIteration to 100, then it works. For png images the default 10 iterations is not enough

imtiazShakil commented 6 months ago

image

the sample png image: SamplePNGImage_5mbmb

anish-anantharaman commented 1 month ago

@imtiazShakil I tried adding the maxIterations parameter as 100. However I am facing the same issue. It is not getting compressed. I am using browser-image-compression version 0.0.1. Any ideas are welcome. Thank you

const options = { useWebWorker: true, maxSizeMB: 2, initialQuality: 0.7, // Lower initial quality to reduce file size maxIterations: 100 };