-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PNG compression loses quality in some cases #172
Comments
I found a hack that works for those who are facing this issue:
|
When looking at your sample images, it is hard to notice that there are quality differences. The algorithm handling jpg and png is different because png can have a transparent background. |
If you do not care about transparent background of png and wanted to treat it as jpg during compression, you can use the For example: |
I haven't been able to determine what exactly about some PNGs that cause the compression algorithm that results in a visible reduction in quality.
The image I was able to reproduce this with is a PNG image that is 451KB big. When it gets compressed (using the code below) it becomes 169KB. If I just change the extension of the file to JPEG, the converted image is 355KB.
Here are the config params:
imageCompression(file, { alwaysKeepResolution: true, maxIteration: 150, maxSizeMB: 0.4, maxWidthOrHeight: 1440, })
Here is the PNG image before:
Here is the PNG image after:
Here is the JPEG image after:
Would be the reasoning behind this and is there something I'm missing that I could do to avoid this?
The text was updated successfully, but these errors were encountered: