Closed ysabri closed 1 year ago
I have noticed that the compression strategy is a bit aggressive, with which the output is 173KB while your config maxSizeMB is 400KB. In the next release, I will increase the initial color depth during compression. So your current config will result in a better larger output image(<400KB).
However, PNG is lossless by design, so the approach in this library to compress PNG images is to reduce the color depth (number of different colors). Since your config restricts the maxSizeMB to 0.4MB, which is quite small, there may not be enough colors to paint your image. You may decide to increase the maxSizeMB or reduce the maxWidthOrHeight or remind the same after the next release.
@ysabri v2.0.1 has been released. You can have a try.
@Donaldcwl Thank you for the quick turn around.
I just tested the change and it seems to be working fine!
Since I have you here, I wanted to ask about the maxIteration, I had set to 150 which made this change feel slow so I removed it and everything still seems to be working fine with the default 10. What should I worry about when it comes to the number?
Sorry I'm opening #172 again, we've heard this complaint from multiple users.
I will give another example here where its more apparent.
The original image (1.74MB):
Compressed PNG (173KB):
Compressed as a JPEG with the same config (221KB):
Both these were with the same config I specified in #172 and is still the case with this image no matter what configs I try. There is always visible loss in quality.
I don't know what to do here, thanks for pointing out that we lose transparent backgrounds in the hack I used in #172, it is something we care about and this issue is preventing us from having.