Compressed image is bigger than the original
ospfranco opened this issue · comments
Once again, thanks for the library! This issue is related to my previous one. I'm basically trying to compress/optimize for file size as much as I can, yet the image I get from the .compress (with level 13) call is bigger than the original one by a huge margin, I imagine because extra bits are being used/padded per pixel.
Any recommendation to aggressively reduce file size?
hi, can you share the smaller image?
Thanks for replying, I gave up on this idea. The image was just a screenshot I took from my desktop using cmd + shift + 4
nothing special about it. Feel free to close the ticket, otherwise just leave it open as future reference for people trying to reduce file size.
okay, i'm still very interested in how the first image is half the size, so if you have time to attach a copy of it, that would be greatly appreciated :)
Sorry, I already deleted the file I was using for testing.
I can give you this image:
I ran it through pngquant which was the library I was looking to replace with swift-png. The image size is as small as it gets (tinyPNG produces an even smaller file, but they are closed source). I would have liked for swift-png to have produced such a small file size, or at least close to it, even if it required tweaking.
ah, that explains it! pngquant
is a lossy image compressor, swift-png
is a lossless image codec. lossy algorithms will of course produce smaller output files, but at the expense of information loss and ability to re-encode.
Makes sense 👍 thanks!